Skip to content

Instantly share code, notes, and snippets.

@corespider
Created August 14, 2020 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corespider/1a9d4f58cbd47c68f35f8e72a6e4e63f to your computer and use it in GitHub Desktop.
Save corespider/1a9d4f58cbd47c68f35f8e72a6e4e63f to your computer and use it in GitHub Desktop.
ASP NETWEBAPI CRUD Delete operation
[ResponseType(typeof(Customer))]
public IHttpActionResult DeleteCustomer(int id)
{
Customer customer = db.Customers.Find(id);
if (customer == null)
{
return NotFound();
}
db.Customers.Remove(customer);
db.SaveChanges();
return Ok(customer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment