public ActionResult Create(CardFirstStepModel model) { if (ModelState.IsValid) { var cardModel = new CardModel { ClientId = model.ClientId }; InitializeModel(cardModel); return View("Save", cardModel); } return View("Create", model); }
public ActionResult Save(CardModel model) { if (ModelState.IsValid) { var dto = Mapper.Map<CardDto>(model); var result = CommandBus.ExecuteCommand(new SaveCardRequest { Value = dto }); if (result.Success) { return RedirectToAction("Index"); } ViewBag.Errors = "Ошибка вставки \n" + string.Join("\n", result.Errors.Select(x => x.Description)); } InitializeModel(model); return View("Save", model); }
private void InitializeModel(CardModel model) { var accounts = CommandBus.ExecuteCommand<IList<LookupItem>>(new AccountLookupListRequest {Value = model.ClientId}); model.AccountLookupItems = accounts.TypedResult ?? new List<LookupItem>(); }