Created
August 14, 2020 11:20
-
-
Save corespider/ace52a68f101fe82a8fdd2bf15da28d6 to your computer and use it in GitHub Desktop.
ASP NET CRUD Web API Post Customer
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 PostCustomer(Customer customer) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return BadRequest(ModelState); | |
} | |
db.Customers.Add(customer); | |
db.SaveChanges(); | |
return CreatedAtRoute("DefaultApi", new { id = customer.CustId }, customer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment