示例#1
0
        // update
        // GET: Wishlist/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = CreateWishlistService();
            var detail  = service.GetWishlistById(id);
            var model   =
                new WishListEdit
            {
                WishListTitle = detail.WishListTitle,
            };

            return(View(model));
        }
示例#2
0
        public bool UpdateWishlist(WishListEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Wishlist
                    .Single(w => w.WishId == model.WishId && w.OwnerId == _userId);

                entity.WishListTitle = model.WishListTitle;
                entity.CreateUtc     = DateTimeOffset.Now;
                entity.ModifiedUtc   = DateTimeOffset.Now;

                return(ctx.SaveChanges() == 1);
            }
        }
示例#3
0
        public ActionResult Edit(int id, WishListEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateWishlistService();

            if (service.UpdateWishlist(model))
            {
                TempData["SaveResult"] = "Your wish list was upated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "This wish list could not be updated.");
            return(View());
        }