public async Task <IActionResult> Update(int id, [Bind("Name,Address")][FromBody] Customer customer) { if (ModelState.IsValid) { try { _context.Update(customer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(customer.Id)) { return(Json(new { success = false, message = "Cannot find customer to update" })); } else { throw; } } return(Json(new { success = true })); } return(Json(new { success = false, message = "Invalid customer given" })); }
public async Task UpdateEmployee(Employee employee) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { if (!EmployeeExists(employee.Id)) { //log to file or table storage } } }