public async Task <IActionResult> PutManager(int id, Manager manager) { if (id != manager.ManagerID) { return(BadRequest()); } _context.Entry(manager).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ManagerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee(int id, Employee employee) { if (id != employee.EmployeeID) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { // Validation check a manager with ManagerID exists in the managers table, and that the ID includes 9 digits if (_context.Managers.Any(e => e.ManagerID == employee.ManagerID) && IDValidation(employee.ID)) { await _context.SaveChangesAsync(); } else { throw new System.ArgumentException("Manager must be in the managers list, and ID must include 9 digits", "ManagerID"); } } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }