public void CreateOrUpdate(EmployeeBM model) { if (model.Id.HasValue) { _employeeStorage.Update(model); } else { _employeeStorage.Insert(model); } }
public void CreateOrUpdate(EmployeeBindingModel model) { var element = employeeStorage.GetElement(new EmployeeBindingModel { Id = model.Id }); if (element != null) { employeeStorage.Update(model); } else { employeeStorage.Insert(model); } }
public void Update(Employee employee) { if (employee.User != null) { if (employee.User.Password.IsNotEmpty()) { employee.User.Password = PasswordHelper.GetHash(employee.User.Password); } else { var old = Get(employee.Id); employee.User.Password = old.User?.Password; } } employeeStorage.Update(employee); }
public void CreateOrUpdate(EmployeeBindingModel model) { var element = EmployeeStorage.GetElement(new EmployeeBindingModel { FirstName = model.FirstName }); if (element != null && element.Id != model.Id) { throw new Exception("Уже есть работник с таким именем"); } if (model.Id.HasValue) { EmployeeStorage.Update(model); } else { EmployeeStorage.Insert(model); } }
public void CreateOrUpdate(EmployeeBindingModel model) { var element = _employeeStorage.GetElement(new EmployeeBindingModel { Login = model.Login, EMail = model.EMail, PhoneNumber = model.PhoneNumber }); if (element != null && element.Id != model.Id) { throw new Exception("Уже есть пользователь с такими данными"); } if (model.Id.HasValue) { _employeeStorage.Update(model); } else { _employeeStorage.Insert(model); } }
public RedirectToActionResult Update(Employee model) { _storage.Update(model); return(RedirectToAction("List", "Employee")); }
public void Update(Employee employee) { _storage.Update(employee); }