public IHttpActionResult PutEmployee(int id, Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.EmpId) { return(BadRequest()); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UpdateProduct(int id, Product product) { using (var swarnacontext = new SwarnaContext()) { swarnacontext.Entry(product).State = EntityState.Modified; try { swarnacontext.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { //return NotFound(); } else { throw; } } } }