Reviewing Our Project Files6:04 with James Churchill
Now that we’ve got our project setup, let’s review the provided files.
For more information about nullable types in C# and .NET, see this page on MSDN.
See this page for more information about HTTP status codes.
Microsoft’s ASP.NET website has a great walkthrough on how to use layout pages to create a consistent look and feel for your websites.
If you want to learn more about the great Bootstrap CSS framework, don’t miss these Treehouse resources.
CTRL+M CTRL+L- Toggles all outlining
CTRL+M CTRL+M- Toggles outlining for the current section
Let's start with reviewing our project files by taking a look 0:00 at the EntriesController class. 0:03 I'll collapse the solution explorer window to make more room for the editor. 0:05 The EntriesController constructor is instantiating an instance of 0:08 the entriesRepository class, 0:12 which we'll be using throughout this course to manage our data. 0:13 We'll take a look at our repositories in just a bit. 0:17 Our controller contains an index action method for our list page. 0:20 Shortly, we'll take a closer look at this method and its associated view. 0:25 We also have add, 0:29 edit, And delete action methods. 0:32 We'll be making changes to these methods as we add functionality to our web app. 0:39 Notice how the edit and 0:44 delete action methods both accept an ID parameter of type int. 0:45 The question mark following the data type indicates that the data type is nullable. 0:49 Meaning that the ID parameter can have a value of null. 0:56 For more information about nullable types, see the teacher's notes. 1:00 Making our ID parameter nullable, allows the entries/edit and 1:05 entries/delete pass to be successfully routed to our action methods. 1:09 If we didn't allow nulls, MVC would throw a routing error. 1:15 Instead, we're checking to see if the ID parameter is null and 1:19 returning a 400 BadRequest HTTPStatusCode in 1:23 order to reject requests that don't include an ID parameter. 1:28 This is in contrast to returning a 404 Not Found HTTPStatusCode 1:32 when an entry can't be found for the provided ID parameter value. 1:38 We'll extend these action methods to do exactly that in a later video. 1:42 See the teachers notes for more information about HTTPStatusCodes. 1:47 Next, let's take a look at our views. 1:52 We have four views, one each for our action methods Add [SOUND], 1:55 Index [SOUND], Edit [SOUND], and Delete [SOUND]. 2:00 These action method and view names map to our crowd action. 2:03 Ad maps to create, index maps to read, 2:08 edit maps to update, and delete maps to well, delete. 2:13 Here's our entries index view. 2:19 We'll take a closer look at this view in the next video. 2:21 The edit and delete views are just stubs at this point. 2:24 In the ad view, contains a basic HTML only version of our add entry form. 2:29 We'll be updating all of these views throughout this course. 2:35 In the shared folder is our layout page, 2:38 which provides the overall look and feel for each of our pages. 2:42 For more information about MVC layout pages, see the teacher's notes. 2:47 Let's finish up our review by taking a look at our project's models and 2:51 repositories. 2:55 The models are located in the Models folder. 2:56 We have two models, activity and entry. 2:59 The activity model contains an activity type enum that defines the list of 3:04 available activities. 3:08 Further down in the class, we can see its properties. 3:10 Id and Name. 3:15 The entry model also contains an enumeration, 3:18 intensity level which defines the available intensity levels. 3:21 Low, medium and high. 3:26 The entry model has more properties than the activity model. 3:29 ID, date, ActivityId, 3:37 Activity, Duration, 3:42 Intensity, Exclude and Notes. 3:47 You might wonder why we need two properties for the activity. 3:53 An activity ID property of type int and an activity property of type activity. 3:57 We'll be taking a closer look at these properties in later videos. 4:02 Now let's look at the repositories in the Data folder. 4:06 We have one for entries, and another for activities. 4:10 The activities repository class contains just a single method, get activities. 4:17 The entries repository class is a little more involved. 4:24 Let's toggle all of the class outlining by pressing Ctrl+M followed by Ctrl+L. 4:27 Then we can hold down the Ctrl key and 4:34 press M twice to expand the namespace and class sections. 4:36 Now we can see that the class contains the following methods. 4:42 GetEntries, GetEntry. 4:47 AddEntry, UpdateEntry and DeleteEntry. 4:53 Both of these repositories use the collections that are defined 5:00 in the data class to provide the data for our web app. 5:04 As mentioned earlier, data would typically be persisted using a database or 5:07 an API given that the code in the repository in data classes 5:12 should be thought of as a work around instead of a best practice. 5:17 If you're using GitHub, let's commit our project files. 5:21 Switch back to the Team Explorer panel. 5:24 Then under the Project section, click the Changes button. 5:27 Under the Changes section, we can see a list of the files that we've added to our 5:30 repo, I'll 5:34 enter a commit message of added project files. 5:40 And then click the down arrow on the Commit All button and 5:46 select the Commit All and Push option. 5:49 This will commit and push our changes to the remote server. 5:55 Next up, we'll take a closer look at our entries list page controller and view. 5:59
You need to sign up for Treehouse in order to download course files.Sign up