From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Getting a single entry

Getting a single entry

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Getting a single entry

- [Instructor] Before we start designing our view, let us first get the entry from the database so then we can show all the data to the users. For that, let us go to our web API project. In the Entries Controller, we are going to create an additional API, which is going to be the same like the GetEntries, but it's going to return just one of them. So I'm going to copy the GetEntries method and then I'll paste it at Line 16. Then change the name to GetEntry. This method is going to take a parameter, which is going to be the id of the entry, so for that, we write in here int id and then instead of returning all the entries, we are going to get only one of them. So for that, we write FirstOrDefault n goes to n.Id is equal to id. Then change the var name to entry, and before you return it, check if this entry already exists. So for that, we write if this entry does not exist, so if it's null, then return a NotFound response. But if it exists, then return the entry. So now, we have the…

Contents