1 00:00:00,540 --> 00:00:04,510 Now that we've installed and configured our DI container, let's update our 2 00:00:04,510 --> 00:00:08,877 controllers actions methods to call the appropriate EntriesRepository methods. 3 00:00:11,600 --> 00:00:15,168 In the first Get action method, let's return a call, 4 00:00:17,547 --> 00:00:21,106 To the entriesRepository.GetList method. 5 00:00:24,411 --> 00:00:28,461 And in the second Get action method, let's return a call to 6 00:00:28,461 --> 00:00:33,164 the entriesRepository.Get method, passing in the id parameter. 7 00:00:40,132 --> 00:00:41,782 In the Post action method, 8 00:00:41,782 --> 00:00:45,592 we need to call the entriesRepository method to add the entry. 9 00:00:51,641 --> 00:00:54,073 And in the Put action method, 10 00:00:54,073 --> 00:00:59,532 we need to call the entriesRepository method to update the entry. 11 00:01:07,320 --> 00:01:10,786 And lastly, in the Delete action method, 12 00:01:10,786 --> 00:01:16,184 we need to call the entriesRepository method to delete the entry. 13 00:01:22,670 --> 00:01:27,470 Set break points in the constructor in the first Get action method, and 14 00:01:27,470 --> 00:01:29,550 press F5 to start debugging. 15 00:01:39,461 --> 00:01:44,641 Using Postman, let's make a Get request 16 00:01:44,641 --> 00:01:49,381 against the api/entries endpoint. 17 00:01:49,381 --> 00:01:52,354 Here we are in the constructor for our API controller. 18 00:01:55,442 --> 00:02:00,309 If we look in the Call Stack window, we can see that the Call Stack includes 19 00:02:00,309 --> 00:02:04,475 a call to the SimpleInjectorWebApiInitializer.Initialize 20 00:02:04,475 --> 00:02:05,125 method. 21 00:02:05,125 --> 00:02:08,190 This is our controller being instantiated 22 00:02:08,190 --> 00:02:11,630 as part of the DI container's verification process. 23 00:02:11,630 --> 00:02:14,690 Press F5 to continue execution. 24 00:02:14,690 --> 00:02:17,530 And we're in the controller constructor again. 25 00:02:17,530 --> 00:02:18,310 This time, 26 00:02:18,310 --> 00:02:21,980 our controller is being substantiated to handle the current request. 27 00:02:21,980 --> 00:02:25,230 If we hover over the entriesRepository parameter, 28 00:02:25,230 --> 00:02:29,845 we can see that we've been passed a reference to an instance which in 29 00:02:29,845 --> 00:02:33,550 turn has a reference to a context class instance. 30 00:02:33,550 --> 00:02:35,960 Looks like our DI container is up and running. 31 00:02:37,500 --> 00:02:39,580 Press F5 to continue execution. 32 00:02:40,610 --> 00:02:43,190 And here we are in the Get action method, 33 00:02:43,190 --> 00:02:47,560 about to make a call to the entriesRepository.GetList method. 34 00:02:47,560 --> 00:02:49,625 Go ahead and continue execution. 35 00:02:52,315 --> 00:02:54,281 And we get an exception. 36 00:02:58,334 --> 00:03:01,500 Right here is the exception message. 37 00:03:01,500 --> 00:03:08,363 Self referencing loop detected with type 'Treehouse.FitnessFrog.Shared.Models.En- 38 00:03:08,363 --> 00:03:11,800 try' Path '[0] .Activity.Entries'. 39 00:03:11,800 --> 00:03:16,110 Looks like we've encountered an issue with serializing our data to JSON. 40 00:03:16,110 --> 00:03:19,700 Next up, let's take a closer look at why this error's occurring, and 41 00:03:19,700 --> 00:03:22,930 how we can configure the JsonSerializer to prevent it.