From the course: .NET Microservices for Azure Developers
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Implementing BreedsController and validations - Azure Tutorial
From the course: .NET Microservices for Azure Developers
Solution: Implementing BreedsController and validations
(upbeat music) - [Instructor] Let me show you how I managed to implement the BreedsController class and how I implemented the logger object. So here's the class. You can see that I'm injecting both ManagementDbContext and the ILogger of BreedsController objects. And here I'm validating if there's nothing in the database, I'm returning 404, and in this other method as well. This method is named GetBreedById, and I'm actually using that as the route name since the route name should be different than the one that we have in the PetsController class. And here you can see that I implemented this try-catch block, since this is the place where I'm using the logger object and returning 500. Down below, you can find the new breed record and I'm using zero as a value for the ID since the entity framework core is going to set the correct ID after the new item is inserted in the database. So let's open up PetsController so you can see that I'm also injecting ILogger of PetsController, validating…
Contents
-
-
-
-
Creating and cloning the repo1m 2s
-
(Locked)
Creating your first microservice using ASP.NET Core1m 54s
-
(Locked)
Creating and registering the DbContext for the microservice5m 49s
-
(Locked)
Creating the PetsController and returning the list of pets2m 36s
-
(Locked)
Obtaining a single pet in the PetsController1m 30s
-
(Locked)
Creating a new pet3m 21s
-
(Locked)
Challenge: Implementing BreedsController and validations1m 5s
-
(Locked)
Solution: Implementing BreedsController and validations1m 35s
-
-
-
-
-