From the course: Advanced ASP.NET Web API 2.2
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Updating and deleting an entity
From the course: Advanced ASP.NET Web API 2.2
Updating and deleting an entity
- Before we move to the next chapter, let us see how we can update or delete an entity. For that, let's go to Visual Studio and see it in action. Let us start with the updating an entity. So for that we need to go to our controller and scroll down after the Post request. In here let's write public async task of IHttp action result, and then we write in here Put. These takes two parameters. The first parameter is going to come from the URL, which is the identifier for the entity, and the second parameter is going to be the entity with the updated values. So, let's write in here FromODataUri, and this is going to be the key of type integer, the second parameter is going to be a student entity. We need to first check two things. First thing that we need to check is if the student entity has valid data, and the next, we need to check if the student's ID is equal to the ID that we have in our URL. Let us start with the model…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Setting up the environment4m 36s
-
(Locked)
Configuring the OData endpoint3m 25s
-
(Locked)
Creating the first OData controller2m 2s
-
(Locked)
Setting up a database4m 4s
-
(Locked)
Reading entities4m 39s
-
(Locked)
Creating and reading a single entity3m 37s
-
(Locked)
Updating and deleting an entity7m 4s
-
(Locked)
-
-
-