public ActionResult Create(EquipmentViewModel equipmentViewModel) { if (ModelState.IsValid) { //var addEquipmentCommand = new AddEquipmentCommand(); Mapper.CreateMap<EquipmentViewModel, AddEquipmentCommand>().ForMember(view => view.Id, o => o.Ignore()); var addEquipmentCommand=Mapper.Map<EquipmentViewModel, AddEquipmentCommand>(equipmentViewModel); _commandProcessor.Process<AddEquipmentCommand, CommandResult>(addEquipmentCommand, ModelState); if (!ModelState.IsValid) return View(); return this.RedirectToAction(c => c.Index(null, null)); } return View(); }
public ActionResult Edit(EquipmentViewModel equipmentViewModel) { if (ModelState.IsValid) { var editEquipmentCommand = new EditEquipmentCommand(); Mapper.CreateMap<EquipmentViewModel, EditEquipmentCommand>(); Mapper.Map(equipmentViewModel, editEquipmentCommand); _commandProcessor.Process<EditEquipmentCommand, CommandResult>(editEquipmentCommand, ModelState); if (!ModelState.IsValid) return View(); return this.RedirectToAction(c => c.Index(null, null)); } return View(); }