1 00:00:00,280 --> 00:00:03,200 Let's start with reviewing our project files by taking a look 2 00:00:03,200 --> 00:00:05,160 at the EntriesController class. 3 00:00:05,160 --> 00:00:08,830 I'll collapse the solution explorer window to make more room for the editor. 4 00:00:08,830 --> 00:00:12,348 The EntriesController constructor is instantiating an instance of 5 00:00:12,348 --> 00:00:13,986 the entriesRepository class, 6 00:00:13,986 --> 00:00:17,860 which we'll be using throughout this course to manage our data. 7 00:00:17,860 --> 00:00:20,980 We'll take a look at our repositories in just a bit. 8 00:00:20,980 --> 00:00:25,470 Our controller contains an index action method for our list page. 9 00:00:25,470 --> 00:00:29,850 Shortly, we'll take a closer look at this method and its associated view. 10 00:00:29,850 --> 00:00:32,760 We also have add, 11 00:00:32,760 --> 00:00:39,520 edit, And delete action methods. 12 00:00:39,520 --> 00:00:44,000 We'll be making changes to these methods as we add functionality to our web app. 13 00:00:44,000 --> 00:00:45,230 Notice how the edit and 14 00:00:45,230 --> 00:00:49,148 delete action methods both accept an ID parameter of type int. 15 00:00:49,148 --> 00:00:56,880 The question mark following the data type indicates that the data type is nullable. 16 00:00:56,880 --> 00:01:00,880 Meaning that the ID parameter can have a value of null. 17 00:01:00,880 --> 00:01:05,020 For more information about nullable types, see the teacher's notes. 18 00:01:05,020 --> 00:01:09,878 Making our ID parameter nullable, allows the entries/edit and 19 00:01:09,878 --> 00:01:15,150 entries/delete pass to be successfully routed to our action methods. 20 00:01:15,150 --> 00:01:19,530 If we didn't allow nulls, MVC would throw a routing error. 21 00:01:19,530 --> 00:01:23,646 Instead, we're checking to see if the ID parameter is null and 22 00:01:23,646 --> 00:01:28,390 returning a 400 BadRequest HTTPStatusCode in 23 00:01:28,390 --> 00:01:32,600 order to reject requests that don't include an ID parameter. 24 00:01:32,600 --> 00:01:38,310 This is in contrast to returning a 404 Not Found HTTPStatusCode 25 00:01:38,310 --> 00:01:42,820 when an entry can't be found for the provided ID parameter value. 26 00:01:42,820 --> 00:01:47,510 We'll extend these action methods to do exactly that in a later video. 27 00:01:47,510 --> 00:01:52,660 See the teachers notes for more information about HTTPStatusCodes. 28 00:01:52,660 --> 00:01:55,250 Next, let's take a look at our views. 29 00:01:55,250 --> 00:02:00,179 We have four views, one each for our action methods Add [SOUND], 30 00:02:00,179 --> 00:02:03,812 Index [SOUND], Edit [SOUND], and Delete [SOUND]. 31 00:02:03,812 --> 00:02:08,609 These action method and view names map to our crowd action. 32 00:02:08,609 --> 00:02:13,770 Ad maps to create, index maps to read, 33 00:02:13,770 --> 00:02:19,470 edit maps to update, and delete maps to well, delete. 34 00:02:19,470 --> 00:02:21,480 Here's our entries index view. 35 00:02:21,480 --> 00:02:24,830 We'll take a closer look at this view in the next video. 36 00:02:24,830 --> 00:02:29,930 The edit and delete views are just stubs at this point. 37 00:02:29,930 --> 00:02:35,440 In the ad view, contains a basic HTML only version of our add entry form. 38 00:02:35,440 --> 00:02:38,950 We'll be updating all of these views throughout this course. 39 00:02:38,950 --> 00:02:41,410 In the shared folder is our layout page, 40 00:02:42,990 --> 00:02:47,410 which provides the overall look and feel for each of our pages. 41 00:02:47,410 --> 00:02:51,850 For more information about MVC layout pages, see the teacher's notes. 42 00:02:51,850 --> 00:02:55,110 Let's finish up our review by taking a look at our project's models and 43 00:02:55,110 --> 00:02:56,580 repositories. 44 00:02:56,580 --> 00:02:59,770 The models are located in the Models folder. 45 00:02:59,770 --> 00:03:04,443 We have two models, activity and entry. 46 00:03:04,443 --> 00:03:08,741 The activity model contains an activity type enum that defines the list of 47 00:03:08,741 --> 00:03:10,206 available activities. 48 00:03:10,206 --> 00:03:12,815 Further down in the class, we can see its properties. 49 00:03:15,597 --> 00:03:18,461 Id and Name. 50 00:03:18,461 --> 00:03:21,661 The entry model also contains an enumeration, 51 00:03:21,661 --> 00:03:26,730 intensity level which defines the available intensity levels. 52 00:03:26,730 --> 00:03:29,600 Low, medium and high. 53 00:03:29,600 --> 00:03:32,790 The entry model has more properties than the activity model. 54 00:03:37,563 --> 00:03:42,579 ID, date, ActivityId, 55 00:03:42,579 --> 00:03:47,139 Activity, Duration, 56 00:03:47,139 --> 00:03:53,530 Intensity, Exclude and Notes. 57 00:03:53,530 --> 00:03:57,070 You might wonder why we need two properties for the activity. 58 00:03:57,070 --> 00:04:02,730 An activity ID property of type int and an activity property of type activity. 59 00:04:02,730 --> 00:04:06,420 We'll be taking a closer look at these properties in later videos. 60 00:04:06,420 --> 00:04:09,250 Now let's look at the repositories in the Data folder. 61 00:04:10,930 --> 00:04:15,510 We have one for entries, and another for activities. 62 00:04:17,080 --> 00:04:22,023 The activities repository class contains just a single method, get activities. 63 00:04:24,375 --> 00:04:27,850 The entries repository class is a little more involved. 64 00:04:27,850 --> 00:04:34,360 Let's toggle all of the class outlining by pressing Ctrl+M followed by Ctrl+L. 65 00:04:34,360 --> 00:04:36,800 Then we can hold down the Ctrl key and 66 00:04:36,800 --> 00:04:41,050 press M twice to expand the namespace and class sections. 67 00:04:42,830 --> 00:04:45,900 Now we can see that the class contains the following methods. 68 00:04:47,400 --> 00:04:51,134 GetEntries, GetEntry. 69 00:04:53,855 --> 00:05:00,520 AddEntry, UpdateEntry and DeleteEntry. 70 00:05:00,520 --> 00:05:04,270 Both of these repositories use the collections that are defined 71 00:05:04,270 --> 00:05:07,990 in the data class to provide the data for our web app. 72 00:05:07,990 --> 00:05:12,660 As mentioned earlier, data would typically be persisted using a database or 73 00:05:12,660 --> 00:05:17,580 an API given that the code in the repository in data classes 74 00:05:17,580 --> 00:05:21,530 should be thought of as a work around instead of a best practice. 75 00:05:21,530 --> 00:05:24,800 If you're using GitHub, let's commit our project files. 76 00:05:24,800 --> 00:05:27,070 Switch back to the Team Explorer panel. 77 00:05:27,070 --> 00:05:30,330 Then under the Project section, click the Changes button. 78 00:05:30,330 --> 00:05:34,216 Under the Changes section, we can see a list of the files that we've added to our 79 00:05:34,216 --> 00:05:40,108 repo, I'll 80 00:05:40,108 --> 00:05:46,330 enter a commit message of added project files. 81 00:05:46,330 --> 00:05:49,698 And then click the down arrow on the Commit All button and 82 00:05:49,698 --> 00:05:52,073 select the Commit All and Push option. 83 00:05:55,586 --> 00:05:59,590 This will commit and push our changes to the remote server. 84 00:05:59,590 --> 00:06:03,780 Next up, we'll take a closer look at our entries list page controller and view.