Ejemplo n.º 1
0
 public ActionResult Remove(EntitieServices.EntitiProductShop.Product pr)
 {
     cart = (List <Item>)Session["cart"];
     cart.RemoveAll(x => x.Product.ProductID == pr.ProductID);
     Session["cart"]  = cart;
     Session["count"] = Convert.ToInt32(Session["count"]) - 1;
     return(RedirectToAction("Myorder", "Cart"));
 }
Ejemplo n.º 2
0
 public ActionResult Create(PaymentViewModel pvm)
 {
     pvm.OrderDate = DateTime.Now;
     cart          = (List <Item>)TempData["cart"];
     if (ModelState.IsValid)
     {
         Payment _payment = PaymentMapper.To_Payment_Create_ViewModel(pvm);
         _repository.Create(_payment);
         _repository.Save();
         List <Order> order = OrderMapper.To_order_Create_Cart(cart, _payment.PaymentID);
         foreach (Order ord in order)
         {
             _repoorder.Create(ord);
             _repoorder.Save();
             EntitieServices.EntitiProductShop.Product pr = _repositoryproduct.Select(ord.ProductId);
             pr.Quantity = pr.Quantity - ord.ProductQuantity;
             _repositoryproduct.Save();
         }
     }
     Session["cart"] = null;
     return(RedirectToAction("Index", "Products"));
 }
Ejemplo n.º 3
0
 public ActionResult Add(EntitieServices.EntitiProductShop.Product pr)
 {
     if (Session["cart"] == null)
     {
         cart = new List <Item>();
         cart.Add(new Item((Models.Product)_productClient.FindProduct(pr.ProductID), 1));
         Session["cart"]  = cart;
         ViewBag.cart     = cart.Count();
         Session["count"] = 1;
     }
     else
     {
         cart = (List <Item>)Session["cart"];
         int index = IsExisting(pr.ProductID);
         if (index == -1)
         {
             cart.Add(new Item((Models.Product)_productClient.FindProduct(pr.ProductID), 1));
             Session["cart"]  = cart;
             ViewBag.cart     = cart.Count();
             Session["count"] = Convert.ToInt32(Session["count"]) + 1;
         }
     }
     return(RedirectToAction("Index", "Products"));
 }