Skip to content

Instantly share code, notes, and snippets.

@A2H111
Created April 8, 2017 04:43
Show Gist options
  • Save A2H111/9c377dd6bfed87b5c5651f3afe7ff80e to your computer and use it in GitHub Desktop.
Save A2H111/9c377dd6bfed87b5c5651f3afe7ff80e to your computer and use it in GitHub Desktop.
//Creating dbcontext class for NorthwindDatabase
NorthwindEntities dbContext = new NorthwindEntities();
[HttpPost]
public IHttpActionResult UpdateCustomer(Customer customer)
{
try
{
//Code to Save the data
dbContext.Entry(customer).State = System.Data.EntityState.Modified;
dbContext.SaveChanges();
//Return Ok response if data saved successfully
return Content(HttpStatusCode.OK, "Data Saved Successfully");
}
catch (Exception ex)
{
return Content(HttpStatusCode.InternalServerError, "Data Save Failed" + ex.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment