public ActionResult Edit([Bind(Include = "ProductID,Quantity,Price")] ProductParmsModel model) { ProductDetail Newlist = new ProductDetail(); if (this._shoppingService.HasSession()) { list = this._shoppingService.GetSession(); Newlist = list.FirstOrDefault(x => x.ProductID == model.ProductID && x.Quantity == model.Quantity && x.Price == model.Price); if (Newlist == null) { Response.Redirect(Url.Action("Index", "Shopping"), true); } else { IList <SelectListItem> item = new List <SelectListItem>(); for (int i = 0; i <= this._shoppingService.GetProductQuantity(model.ProductID); i++) { item.Add(new SelectListItem() { Selected = model.Quantity == i ? true : false, Text = i.ToString(), Value = i.ToString() }); } ViewBag.ProductDDL = item; } } else { Response.Redirect(Url.Action("Index", "Shopping"), true); } return(View(Newlist)); }
public ActionResult DeleteConfirmed([Bind(Include = "ProductID,Quantity,Price")] ProductParmsModel model) { if (this._shoppingService.HasSession()) { list = this._shoppingService.GetSession(); var Newlist = list.FirstOrDefault(x => x.ProductID == model.ProductID && x.Quantity == model.Quantity && x.Price == model.Price); if (Newlist != null) { list.Remove(Newlist); } this._shoppingService.SetSession(list); } return(RedirectToAction("Index")); }
public ActionResult Delete([Bind(Include = "ProductID,Quantity,Price")] ProductParmsModel model) { ProductDetail Newlist = new ProductDetail(); if (this._shoppingService.HasSession()) { list = this._shoppingService.GetSession(); Newlist = list.FirstOrDefault(x => x.ProductID == model.ProductID && x.Quantity == model.Quantity && x.Price == model.Price); if (Newlist == null) { Response.Redirect(Url.Action("Index", "Shopping"), true); } } else { Response.Redirect(Url.Action("Index", "Shopping"), true); } return(View(Newlist)); }
public ActionResult Modify([Bind(Include = "ProductID,Quantity,Price")] ProductParmsModel model) { ProductDetail Oldlist = new ProductDetail(); if (this._shoppingService.HasSession()) { list = this._shoppingService.GetSession(); Oldlist = list.FirstOrDefault(x => x.ProductID == model.ProductID && x.Price == model.Price); if (Oldlist == null) { Response.Redirect(Url.Action("Index", "Shopping"), true); } else { list.FirstOrDefault(x => x.ProductID == model.ProductID && x.Price == model.Price).Quantity = model.Quantity; this._shoppingService.SetSession(list); } } return(RedirectToAction("Index")); }