Exemplo n.º 1
0
 public void CreateOrUpdate(EmployeeBM model)
 {
     if (model.Id.HasValue)
     {
         _employeeStorage.Update(model);
     }
     else
     {
         _employeeStorage.Insert(model);
     }
 }
Exemplo n.º 2
0
        public void CreateOrUpdate(EmployeeBindingModel model)
        {
            var element = employeeStorage.GetElement(new EmployeeBindingModel {
                Id = model.Id
            });

            if (element != null)
            {
                employeeStorage.Update(model);
            }
            else
            {
                employeeStorage.Insert(model);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public RedirectToActionResult Update(Employee model)
 {
     _storage.Update(model);
     return(RedirectToAction("List", "Employee"));
 }
Exemplo n.º 7
0
 public void Update(Employee employee)
 {
     _storage.Update(employee);
 }