public ActionResult ConfirmPay(int id) { if (Session["email"] == null) { return(RedirectToAction("WelcomeHome", "user")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product product = db.Products.Find(id); //DB product tempProduct p = products.SingleOrDefault(pp => pp.ID == id); // temp DB if (product == null) { return(HttpNotFound()); } product.Quantity = product.Quantity - p.Pcounter; db.SaveChanges(); tempProduct PDelete = products.SingleOrDefault(pp => pp.ID == id); products.Remove(PDelete); return(RedirectToAction("shop")); }
public ActionResult CartSet(int id, string name, decimal price, int quantaty, string description) { if (Session["email"] == null) { return(RedirectToAction("WelcomeHome", "user")); } tempProduct p = new tempProduct() { ID = id, name = name, price = price, quantaty = quantaty }; if (p.Pcounter != p.quantaty) { p.Pcounter += 1; } tempProduct pFound = products.SingleOrDefault(pp => pp.ID == id); if (pFound == null) { p.totalPrice = price; products.Add(p); } else { return(RedirectToAction($"addAnotherToCart/{id}")); } return(RedirectToAction("cart")); }
public ActionResult addAnotherToCart(int id) { if (Session["email"] == null) { return(RedirectToAction("WelcomeHome", "user")); } tempProduct p = products.SingleOrDefault(pp => pp.ID == id); if (p.Pcounter != p.quantaty) { p.totalPrice = ++p.Pcounter * p.price; } return(RedirectToAction("cart")); }