Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ASP NET CRUD Web API Post Customer
[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