示例#1
0
 public ActionResult Edit(FormationViewModel frmViewModel)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     _repository.Update(Mapper.Map <Formation>(frmViewModel));
     return(RedirectToAction("Index"));
 }
        public Formation Update(ChangeFormationCommand command)
        {
            var formation = _repository.GetOne(command.Id);

            if (!string.IsNullOrEmpty(command.Name))
            {
                formation.ChangeName(command.Name);
            }
            if (!string.IsNullOrEmpty(command.Description))
            {
                formation.ChangeDescription(command.Description);
            }

            _repository.Update(formation);

            if (Commit())
            {
                return(formation);
            }

            return(null);
        }