예제 #1
0
        // GET: AccountOffers/Edit/5
        public ActionResult Edit(int id)
        {
            var service = CreateAccountOfferService();
            var detail  = service.GetAccountOfferById(id);
            var model   =
                new AccountOfferEdit
            {
                OfferId  = detail.OfferId,
                Title    = detail.Title,
                Body     = detail.Body,
                IsActive = detail.IsActive
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Edit(int id, AccountOfferEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.OfferId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateAccountOfferService();

            if (service.UpdateAccountOffer(model))
            {
                TempData["SaveResult"] = "Your offer was modified.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your offer could not be updated.");
            return(View(model));
        }