public IHttpActionResult UpdateDepartment(int departmentId, DepartmentDto updatedDepartmentDto) { var department = context.Departments .Single(d => d.Id == departmentId); department.Name = updatedDepartmentDto.Name; context.SaveChanges(); return Ok(updatedDepartmentDto); }
public IHttpActionResult AddDepartment(DepartmentDto newDepartmentDto) { var newDepartment = new Department { Name = newDepartmentDto.Name, AvailableSince = DateTime.Now }; context.Departments.Add(newDepartment); context.SaveChanges(); newDepartmentDto.Id = newDepartment.Id; return Ok(newDepartmentDto); }