public async Task <IActionResult> UpdateEmployee(Guid id, [FromBody] UpdateEmployeeVm vm) { try { return(new OkObjectResult(await EmployeeLogic.UpdateEmployee(id, vm))); } catch (Exception ex) { return(ExceptionsHelper.HandleException(ex)); } }
public async Task <Employee> UpdateEmployee(Guid id, UpdateEmployeeVm vm) { var existingEmployee = await EmployeesRepo.FindById(id); if (existingEmployee == null) { throw new EntityNotFoundException(); } var updatedEmployee = new Employee(new EmployeeConstructorInput { ID = id, Address = vm.Address, DateOfBirth = vm.DateOfBirth, Department = vm.Department, Name = vm.Name, Role = vm.Role, IsActive = vm.IsActive }); updatedEmployee.Validate(); await EmployeesRepo.Update(id, updatedEmployee); return(updatedEmployee); }