public async Task <IActionResult> PutDepartment(int id, Department department) { if (id != department.Id) { return(BadRequest()); } _context.Entry(department).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <DBStateKey> UpdateEmployee(int id, Employee employee) { if (id != employee.Id) { return(DBStateKey.IdIsDifferent); } if (!await EmployeeExists(id)) { return(DBStateKey.IdIsNotExist); } EmpRepo.Update(employee); try { await DB.SaveChangesAsync(); } catch (DbUpdateConcurrencyException exception) { throw exception; } return(DBStateKey.Success); }