public ActionResult Edit(EmployeeViewModel employeeViewModel) { if (ModelState.IsValid) { var editEmployeeCommand = new EditEmployeeCommand(); Mapper.CreateMap<EmployeeViewModel, EditEmployeeCommand>(); Mapper.Map(employeeViewModel, editEmployeeCommand); CommandProcessor.Process<EditEmployeeCommand, CommandResult>(editEmployeeCommand, ModelState); if (!ModelState.IsValid) return View(); return this.RedirectToAction(c => c.Index(null, null)); } return View(); }
public ActionResult Create(EmployeeViewModel employeeViewModel) { if (ModelState.IsValid) { var addEmployeeCommand = new AddEmployeeCommand(); Mapper.CreateMap<EmployeeViewModel, AddEmployeeCommand>().BeforeMap((s, d) => d.Password = s.ConfirmPassword); Mapper.Map(employeeViewModel, addEmployeeCommand); CommandProcessor.Process<AddEmployeeCommand, CommandResult>(addEmployeeCommand, ModelState); if (!ModelState.IsValid) return View(); return this.RedirectToAction(c => c.Index(null, null)); } return View(); }