Created
August 14, 2020 11:46
-
-
Save corespider/1a9d4f58cbd47c68f35f8e72a6e4e63f to your computer and use it in GitHub Desktop.
ASP NETWEBAPI CRUD Delete operation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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