public async Task <ActionResult <Department> > PostDepartment([FromBody] Department Department) { _context.Departments.Add(Department); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDepartment", new { id = Department.Id }, Department)); }
public async Task <IActionResult> PutEmployee(int id, [FromBody] Employee employee) { 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()); }