public ActionResult Create() { var giftcardEdit = new GiftCardEdit { }; return(View(giftcardEdit)); }
public ActionResult Create(GiftCardEdit giftcardEdit) { if (_giftcardQueryService.IsCodeUnique(giftcardEdit.GiftCode)) { ModelState.AddModelError("GiftCode", "Gift code must be unique"); } if (ModelState.IsValid) { var giftcardUpdate = Mapper.Map <GiftCardUpdate>(giftcardEdit); _giftcardCommandService.Add(giftcardUpdate); return(RedirectToRoute("admin-giftcards")); } return(View(giftcardEdit)); }
public ActionResult Edit(GiftCardEdit giftcardEdit) { if (_giftcardQueryService.IsCodeUnique(giftcardEdit.GiftCode, giftcardEdit.Id)) { ModelState.AddModelError("GiftCode", "Gift code must be unique"); } if (!ModelState.IsValid) { return(View(giftcardEdit)); } var giftcardUpdate = Mapper.Map <GiftCardUpdate>(giftcardEdit); _giftcardCommandService.Update(giftcardUpdate); TempData["Info"] = "GiftCard updated"; return(RedirectToRoute("admin-giftcard-edit", new { giftcardEdit.Id })); }