From the course: Building and Securing Restful APIs in .NET

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Implement resource DELETE

Implement resource DELETE

- [Instructor] Sometimes, we not only want to create or update, we also want to delete items out of our system. So we go back over our controller here, we've got our delete operation. Kind of sad and empty there. Let's go ahead and take some of these attributes from here so we don't have to retype them. Come down to the delete, put those in. So the 404 is valid. We might try and delete something and not find it. We could get the No Content, probably not going to have a client error 'cause we're really just passing the delete identifier. We'll make this our async task via action result again for delete. And again, we'll do some copy paste here, we'll grab this, try catch here, and we'll do the first operation where we pull that up and we'll return a NotFound. There's the end of our try and do a catch, add that in, and we'll just grab the same error we've... We'll paste that down here. We're going to say problem deleting employee resource. So if we don't find them, we're going to return…

Contents