1 00:00:00,290 --> 00:00:03,980 Now that the first part of the solution setup process is complete, 2 00:00:03,980 --> 00:00:06,090 setting up the class library project. 3 00:00:06,090 --> 00:00:09,070 We're ready to work on the second part of the process, 4 00:00:09,070 --> 00:00:12,380 setting up the ASP.NET MVC project. 5 00:00:12,380 --> 00:00:16,540 Right click on the solution and select Add, New Project. 6 00:00:16,540 --> 00:00:19,750 Select the web category on the left. 7 00:00:19,750 --> 00:00:23,620 And then select the ASP.NET Web Application project template. 8 00:00:26,407 --> 00:00:31,218 Name the project, ComicBookLibraryManagerWebApp. 9 00:00:31,218 --> 00:00:40,760 Verify that the selected .NET Framework version is set to .NET Framework 4.6.1. 10 00:00:40,760 --> 00:00:41,796 And then click the OK button. 11 00:00:44,960 --> 00:00:48,607 In the new ASP.NET Web Application dialogue, 12 00:00:48,607 --> 00:00:53,640 select the Empty project template, and check the MVC check box. 13 00:00:53,640 --> 00:00:59,164 So Visual Studio will add the folders, and core references for the MVC web framework. 14 00:00:59,164 --> 00:01:02,902 Well then to hold off on adding a unit test project, and 15 00:01:02,902 --> 00:01:06,350 Authentication is set to No Authentication. 16 00:01:06,350 --> 00:01:07,840 Click OK to add the project. 17 00:01:11,020 --> 00:01:14,310 Next, let's add EF to the the MVC project 18 00:01:33,282 --> 00:01:36,280 And let's add a reference to the class library project. 19 00:01:37,370 --> 00:01:40,437 Be sure to just select the ComicBookShared project and click OK. 20 00:01:43,120 --> 00:01:47,167 Now, we are ready to download the starter files for the web app, and 21 00:01:47,167 --> 00:01:49,120 add them to the MVC project. 22 00:01:49,120 --> 00:01:53,460 The starter files contain a set of controllers, view models, and 23 00:01:53,460 --> 00:01:55,990 views for each page within our web app. 24 00:01:55,990 --> 00:01:59,630 That way, we don't have to start building our web app from scratch. 25 00:01:59,630 --> 00:02:03,440 I've already downloaded the zip file to my desktop, and unzipped it. 26 00:02:03,440 --> 00:02:06,000 If you're following along, see the teacher's notes for 27 00:02:06,000 --> 00:02:07,790 a link to download the files. 28 00:02:07,790 --> 00:02:11,750 After you've unzipped the archive, copy it's contents to the clipboard. 29 00:02:11,750 --> 00:02:15,698 Back in Visual Studio, right click on the MVC project and 30 00:02:15,698 --> 00:02:18,340 select Open Folder in File Explorer. 31 00:02:18,340 --> 00:02:21,750 Then paste the clipboard contents into the root of the project. 32 00:02:21,750 --> 00:02:25,130 When prompted, choose to Replace the files in the destination. 33 00:02:30,730 --> 00:02:34,740 Click the Show All Files button in the Solution Explorer toolbar, 34 00:02:34,740 --> 00:02:38,677 in order to show the files that we added to the project folder, but 35 00:02:38,677 --> 00:02:41,560 haven't yet been added to the project itself. 36 00:02:41,560 --> 00:02:47,460 Right click on the Content folder, and select, Include In Project. 37 00:02:47,460 --> 00:02:50,990 In the Controller's folder, include all four of the controller files. 38 00:02:54,573 --> 00:02:56,570 And include the fonts folder. 39 00:03:03,136 --> 00:03:04,959 We can remove the Models folder, 40 00:03:04,959 --> 00:03:08,960 as all of our entities are located in the class library project. 41 00:03:08,960 --> 00:03:15,390 Include the Scripts folder, And the ViewModels folder. 42 00:03:17,580 --> 00:03:23,563 In the Views folder, include the Artists, ComicBookArtist, 43 00:03:23,563 --> 00:03:29,900 ComicBooks, Series, Shared, and the _ViewStart.cshmtl file 44 00:03:42,816 --> 00:03:46,802 There is one more thing we need to do before we're ready to test the web app. 45 00:03:46,802 --> 00:03:51,060 The ComicBooksController add post action method expects the comicBook 46 00:03:51,060 --> 00:03:56,160 entity to have an AddArtist method that accepts two integer values. 47 00:03:56,160 --> 00:03:58,784 One for the ArtistId, and another for the RoleId. 48 00:04:00,790 --> 00:04:03,010 Here in Notepad, I have the code for 49 00:04:03,010 --> 00:04:06,430 the method that we need to add to the comicBook entity. 50 00:04:06,430 --> 00:04:09,550 If you're following along, you can find this code in the teacher's notes. 51 00:04:11,703 --> 00:04:13,560 I'll copy this code to the clipboard. 52 00:04:16,248 --> 00:04:20,409 Open the comicBook entity class in the class library project, and 53 00:04:20,409 --> 00:04:23,540 paste the code below the last method in the class. 54 00:04:33,589 --> 00:04:36,280 Now, let's try running the app. 55 00:04:36,280 --> 00:04:41,983 Be sure to set the MVC project to be start up project and press F5. 56 00:04:47,310 --> 00:04:49,340 Here's our web apps default or home page. 57 00:04:49,340 --> 00:04:52,533 The Comic Books page. 58 00:04:52,533 --> 00:04:56,339 There aren't any comic books being displayed, but that makes sense, 59 00:04:56,339 --> 00:05:00,019 as we haven't updated the action method that handled the request for 60 00:05:00,019 --> 00:05:03,840 this page to query our database context with a list of comics. 61 00:05:03,840 --> 00:05:05,620 We'll do that in the next section. 62 00:05:06,760 --> 00:05:11,940 Here is the Series page, and the Artists page. 63 00:05:11,940 --> 00:05:14,110 Going back to the Comic Books page, 64 00:05:14,110 --> 00:05:18,630 we can click the ADD COMIC BOOK button to view the add comic book page. 65 00:05:18,630 --> 00:05:22,810 Notice that none of the drop down list contain any items. 66 00:05:22,810 --> 00:05:26,020 again, we will work on fixing that in the next section. 67 00:05:26,020 --> 00:05:29,079 Notice the labels with the Series, IssueNumber, 68 00:05:29,079 --> 00:05:32,000 PublishedOn, and AverageRating fields. 69 00:05:32,000 --> 00:05:37,170 Ideally, the label for the Series field would be just the text series and 70 00:05:37,170 --> 00:05:38,555 not SeriesId. 71 00:05:53,680 --> 00:05:57,115 Here's the call to the LabelFor HTML helper method that's 72 00:05:57,115 --> 00:05:59,640 generating the series field label. 73 00:05:59,640 --> 00:06:03,617 SeriesId is the name of the ComicBook entity property return from 74 00:06:03,617 --> 00:06:07,635 the lambda expression that is being pass to the LabelFor method. 75 00:06:07,635 --> 00:06:13,600 How can we get the series field label to display as series instead of SeriesId. 76 00:06:13,600 --> 00:06:17,480 If you're following along, try fixing this issue as an exercise, 77 00:06:17,480 --> 00:06:19,810 before you proceed to the next video. 78 00:06:19,810 --> 00:06:22,590 After the break, I'll show you how I resolved this issue.