public IHttpActionResult UpdateEmployee(int employeeId, EmployeeDto updatedEmployeeDto) { var employee = context.Employees .Single(e => e.Id == employeeId); employee.FirstName = updatedEmployeeDto.FirstName; employee.LastName = updatedEmployeeDto.LastName; employee.DayOfBirth = updatedEmployeeDto.DayOfBirth; employee.EmailAddress = updatedEmployeeDto.EmailAddress; employee.DepartmentId = updatedEmployeeDto.DepartmentId; context.SaveChanges(); return Ok(updatedEmployeeDto); }
public IHttpActionResult AddEmployee(EmployeeDto newEmployeeDto) { var newEmployee = new Employee { FirstName = newEmployeeDto.FirstName, LastName = newEmployeeDto.LastName, DayOfBirth = newEmployeeDto.DayOfBirth, EmailAddress = newEmployeeDto.EmailAddress, DepartmentId = newEmployeeDto.DepartmentId, AvailableSince = DateTime.Now }; context.Employees.Add(newEmployee); context.SaveChanges(); return Ok(newEmployeeDto); }