コード例 #1
0
        public ActionResult Create()
        {
            var giftcardEdit = new GiftCardEdit
            {
            };

            return(View(giftcardEdit));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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 }));
        }