1 00:00:00,000 --> 00:00:04,587 [MUSIC] 2 00:00:04,587 --> 00:00:08,396 We've made great progress on the Comic Book Library Manager web app, but 3 00:00:08,396 --> 00:00:10,040 we're still not done yet. 4 00:00:10,040 --> 00:00:14,110 We still need to finish the series and artists sections in this. 5 00:00:14,110 --> 00:00:19,300 The last section of this course, you'll do exactly that by completing two exercises. 6 00:00:19,300 --> 00:00:23,120 One exercise for each section of the web app that needs to be completed. 7 00:00:23,120 --> 00:00:25,730 First up, completing the series section. 8 00:00:25,730 --> 00:00:27,930 Let's start with a quick review of the finished pages. 9 00:00:29,380 --> 00:00:31,480 Here's the completed version of the web app. 10 00:00:31,480 --> 00:00:34,972 To browse to the series section, just click on series in the menu. 11 00:00:37,360 --> 00:00:39,290 We only have three series. 12 00:00:40,290 --> 00:00:44,760 Bone, The Amazing Spinder-Man and The Invisible Iron-Man. 13 00:00:44,760 --> 00:00:48,120 To view the detail for the series, click on one of the detail buttons 14 00:00:48,120 --> 00:00:50,450 displayed to the right of the series titles. 15 00:00:50,450 --> 00:00:52,890 In addition to the series' title and description, 16 00:00:52,890 --> 00:00:57,670 the series detail page displays the comic books that are associated with the series. 17 00:00:58,770 --> 00:01:02,730 And we have buttons that allow us to edit or delete the series. 18 00:01:02,730 --> 00:01:07,920 The edit Series page allows us to change the series title or description. 19 00:01:07,920 --> 00:01:11,871 And the Delete Series page allows us to confirm the deletion of a series. 20 00:01:14,231 --> 00:01:17,220 Clicking the back button returns us to the Series list page. 21 00:01:17,220 --> 00:01:20,599 To add a series, click on the Add Series button. 22 00:01:22,885 --> 00:01:26,563 Add a series title, and click the Save button. 23 00:01:29,395 --> 00:01:33,501 Once the series has been added, we're redirected to the detail page for 24 00:01:33,501 --> 00:01:34,850 the new series. 25 00:01:34,850 --> 00:01:35,997 All of the actions for 26 00:01:35,997 --> 00:01:39,772 the series related pages are defined in the Series Controller Class. 27 00:01:42,137 --> 00:01:45,400 Let's review the to do comments in this class. 28 00:01:45,400 --> 00:01:48,870 Our first to do comment is in the index action method. 29 00:01:48,870 --> 00:01:52,480 We need to write a query that retrieves a list of series. 30 00:01:52,480 --> 00:01:55,920 Our next to do comment is in the detail action method. 31 00:01:55,920 --> 00:01:59,050 We need a query to retrieve a single series. 32 00:01:59,050 --> 00:02:03,390 Use the action methods ID parameter to determine which series to retrieve. 33 00:02:04,860 --> 00:02:07,640 No changes are needed in the add get action method. 34 00:02:09,620 --> 00:02:13,980 But in the add post action method, after we validate a series and 35 00:02:13,980 --> 00:02:18,080 check if the model state is valid, we need to add the series. 36 00:02:18,080 --> 00:02:23,200 Notice that the action methods parameter is an instance of the series entity class, 37 00:02:23,200 --> 00:02:25,230 instead of a view model. 38 00:02:25,230 --> 00:02:28,980 Why bind directly to an entity class, instead of a view model? 39 00:02:28,980 --> 00:02:33,340 Well, the form to add or edit a series is relatively simple. 40 00:02:33,340 --> 00:02:35,160 It's just two text fields. 41 00:02:35,160 --> 00:02:38,790 One for the series title and another for the description. 42 00:02:38,790 --> 00:02:41,970 While you technically could use a view model in this case 43 00:02:41,970 --> 00:02:43,840 it certainly isn't necessary. 44 00:02:43,840 --> 00:02:48,780 As the view doesn't require any additional data items in order to be rendered. 45 00:02:48,780 --> 00:02:53,490 In the edit get action method we just need a query to retrieve a series. 46 00:02:53,490 --> 00:02:56,740 You should be able to reuse the query from the detail action method. 47 00:02:57,940 --> 00:03:02,600 In the edit post action method, afer we validate the series, and 48 00:03:02,600 --> 00:03:06,370 check if the model's data's valid, we need to update the series. 49 00:03:06,370 --> 00:03:10,370 And just like the add post action method, the action method's parameter 50 00:03:10,370 --> 00:03:14,100 is an instance of the series in the class, instead of a view model. 51 00:03:15,180 --> 00:03:17,960 Now, lets look at the delete action methods. 52 00:03:17,960 --> 00:03:19,412 In the get action method, 53 00:03:19,412 --> 00:03:24,060 we need a query to retrieve the series that the user is wanting to delete. 54 00:03:24,060 --> 00:03:27,720 Again, you should be able to reuse the query from the detail or 55 00:03:27,720 --> 00:03:29,620 edit get action methods. 56 00:03:29,620 --> 00:03:34,372 In the post action method, we need to do the actual deletion of the series 57 00:03:37,881 --> 00:03:42,682 And lastly the validate series method, which checks if the series title that is 58 00:03:42,682 --> 00:03:46,730 being added isn't already in use by another series. 59 00:03:46,730 --> 00:03:48,470 To do that you'll need to check for 60 00:03:48,470 --> 00:03:51,880 the existence of a series that has the same title property value. 61 00:03:52,880 --> 00:03:55,450 And that's all of the to dos. 62 00:03:55,450 --> 00:03:56,980 Now it's your turn. 63 00:03:56,980 --> 00:04:00,890 You can use repositories, or query command classes. 64 00:04:00,890 --> 00:04:04,960 You could even just use the context directly in the controller action methods. 65 00:04:04,960 --> 00:04:07,190 The choice is yours. 66 00:04:07,190 --> 00:04:09,868 I'll be using a repository for my solution. 67 00:04:09,868 --> 00:04:12,960 Just in case you want to use the same approach as I do. 68 00:04:12,960 --> 00:04:16,090 The important thing is to try to do the work. 69 00:04:16,090 --> 00:04:18,750 Even if you don't complete all of the tasks, 70 00:04:18,750 --> 00:04:22,580 just trying will help you to retain what you learned in this course. 71 00:04:22,580 --> 00:04:26,300 If you get stuck, be sure to review the ComicBooks controller class, 72 00:04:26,300 --> 00:04:28,160 as it contains action methods and 73 00:04:28,160 --> 00:04:32,430 ef queries that are similar to what needs to be done for the series controller. 74 00:04:32,430 --> 00:04:35,240 In the next video, I'll walk you through my solution.