public ActionResult AddItem(int id) { Activity activity = repository.GetFilm(id); WishlistItem wishlistItem = new WishlistItem(); wishlistItem.name = activity.name; wishlistItem.location = activity.location; wishlistItem.startTime = activity.startTime; wishlistItem.endTime = activity.endTime; wishlistItem.actID = activity.Id; wishlistItem.persons = null; wishlistItem.type = "Film"; return View(wishlistItem); }
public ActionResult EditItem(WishlistItem wishlistItem) { if (ModelState.IsValid) { Wishlist wishlist = (Wishlist)Session["active_wishlist"]; WishlistItem oldWishlistItem = wishlist.wishlistItems.SingleOrDefault(c => c.Id == wishlistItem.Id); wishlist.wishlistItems.Remove(oldWishlistItem); wishlist.wishlistItems.Add(wishlistItem); wishlist.Id++; Session["active_wishlist"] = wishlist; return RedirectToAction("Index"); } return View(wishlistItem); }
public ActionResult AddItem(WishlistItem wishlistItem) { if (ModelState.IsValid) { Wishlist wishlist = new Wishlist(); if (!(Session["active_wishlist"] == null)) { wishlist = (Wishlist)Session["active_wishlist"]; wishlist.wishlistItems.Add(wishlistItem); } else { wishlist.wishlistItems.Add(wishlistItem); Session["active_wishlist"] = wishlist; } return RedirectToAction("Index", "Wishlist"); } return View(wishlistItem); }
public void RemoveWishlistItem(WishlistItem wishlistItem) { List<WishlistItem> toBeRemoved = ctx.WishlistItems.Where(c => c.Id == wishlistItem.Id).ToList(); foreach(var i in toBeRemoved) ctx.WishlistItems.Remove(i); ctx.SaveChanges(); }