public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutWorkshopObject([FromRoute] int id, [FromBody] WorkshopObject workshopObject) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != workshopObject.Id) { return(BadRequest()); } _context.Entry(workshopObject).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkshopObjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] string newPassword) { var employee = await _db.Employees.SingleOrDefaultAsync(m => m.Id == id); if (employee == null) { return(NotFound()); } var account = await _db.UsersAccounts.SingleOrDefaultAsync(u => u.EmployeeId == id); if (account == null) { return(NotFound()); } account.Password = newPassword; _db.Entry(account).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }