public void EditEmployee(EmployeeChangeModel model) { _logger.LogInformation($"{MethodBase.GetCurrentMethod().Name} started"); var employee = _repositories.Employees.Get(model.EmployeeId); if (employee == null) { throw new LogicException("There is no Employee with that Id"); } employee.BirthDate = model.BirthDate == null ? employee.BirthDate : model.BirthDate; employee.City = string.IsNullOrEmpty(model.City) ? employee.City : model.City; employee.Country = string.IsNullOrEmpty(model.Country) ? employee.Country : model.Country; employee.Region = string.IsNullOrEmpty(model.Region) ? employee.Region : model.Region; employee.Title = string.IsNullOrEmpty(model.Title) ? employee.Title : model.Title; employee.TitleOfCourtesy = string.IsNullOrEmpty(model.TitleOfCourtesy) ? employee.TitleOfCourtesy : model.TitleOfCourtesy; employee.FirstName = string.IsNullOrEmpty(model.FirstName) ? employee.FirstName : model.FirstName; employee.LastName = string.IsNullOrEmpty(model.LastName) ? employee.LastName : model.LastName; _repositories.Employees.Update(employee); _repositories.SaveChanges(); _logger.LogInformation($"{MethodBase.GetCurrentMethod().Name} finished"); }
public IActionResult Edit([FromQuery] EmployeeChangeModel model) { _employeeOperations.EditEmployee(model); return(Ok()); }