Exemplo n.º 1
0
        // GET: Admin/Cart
        public ActionResult Index()
        {
            var cart = Session[cartSession];
            var list = new ListCartItem();

            if (cart != null)
            {
                list = (ListCartItem)cart;
            }
            return(View(list));
        }
Exemplo n.º 2
0
        public JsonResult UpdateQuantityItem()
        {
            var cart = Session[cartSession];
            var list = new ListCartItem();

            if (cart != null)
            {
                list = (ListCartItem)cart;
            }
            return(Json(new
            {
                quantity = list.TotalQuantity
            }));
        }
Exemplo n.º 3
0
 public ActionResult Pay(Order collection)
 {
     if (ModelState.IsValid)
     {
         var cart = Session[cartSession];
         var list = new ListCartItem();
         if (cart != null)
         {
             list = (ListCartItem)cart;
         }
         var IDOrder = new OrderModel().Create(collection);
         foreach (var item in list.Item)
         {
             new OrderDetailModel().Create(IDOrder, item.Book.ID, item.Quantity, (item.Book.PromotionPrice < item.Book.Price) ? item.Book.PromotionPrice : item.Book.Price);
         }
     }
     return(RedirectToAction("", "gio-hang"));
 }
Exemplo n.º 4
0
        public JsonResult AddCart(int IDBook, int quantity)
        {
            var cart = Session[cartSession];

            if (cart != null)
            {
                var list = (ListCartItem)cart;
                if (list.Item.Exists(x => x.Book.ID == IDBook))
                {
                    var Item = list.Item.SingleOrDefault(x => x.Book.ID == IDBook);
                    list.TotalQuantity += quantity;
                    list.Totalmoney    += quantity * ((Item.Book.PromotionPrice < Item.Book.Price) ? Item.Book.PromotionPrice : Item.Book.Price).GetValueOrDefault(0);
                    Item.Quantity      += quantity;
                }
                else
                {
                    var item = new CartItem();
                    item.Book     = new BookModel().GetItemAtID(IDBook);
                    item.Quantity = quantity;
                    list.Item.Add(item);
                    list.TotalQuantity += quantity;
                    list.Totalmoney    += quantity * ((item.Book.PromotionPrice < item.Book.Price) ? item.Book.PromotionPrice : item.Book.Price).GetValueOrDefault(0);
                }
                Session[cartSession] = list;
            }
            else
            {
                var list = new ListCartItem();
                var item = new CartItem();
                item.Book     = new BookModel().GetItemAtID(IDBook);
                item.Quantity = quantity;
                list.Item.Add(item);
                list.TotalQuantity   = quantity;
                list.Totalmoney     += quantity * ((item.Book.PromotionPrice < item.Book.Price) ? item.Book.PromotionPrice : item.Book.Price).GetValueOrDefault(0);
                Session[cartSession] = list;
            }
            return(Json(new
            {
                status = true
            }));
        }