Exemplo n.º 1
0
        public ActionResult ShoppingCart(int id, itemCartViewModel model)
        {
            string            name;
            ItemCartDal       itemDal = new ItemCartDal();
            TicketsDal        dal     = new TicketsDal();
            var               item    = dal.TicketsList.Where(a => a.ID == id).FirstOrDefault();
            itemCartViewModel mvm     = new itemCartViewModel();
            List <ItemCart>   cart    = new List <ItemCart>();

            mvm.ItemCart = new ItemCart();
            mvm.ITEMS    = cart;
            if (Session["cart"] == null)
            {
                //List<ItemCart> cart = new List<ItemCart>();
                mvm.ITEMS.Add(new ItemCart {
                    ID        = item.ID,
                    MOVIENAME = item.MOVIENAME,
                    SHOWTIME  = item.SHOWTIME,
                    SEAT      = item.SEAT,
                    COST      = item.COST,
                    Quantity  = 1
                });
                //itemDal.itemsCart.Add(mvm.ITEMS[index]);
                //index++;
                Session["cart"] = mvm.ITEMS;
            }
            else
            {
                //List<ItemCart> cart = (List<ItemCart>)Session["cart"];
                int index = isExist(id);
                if (index != -1)
                {
                    //cart[index].Quantity++;
                    mvm.ITEMS[index].Quantity++;
                }
                else
                {
                    mvm.ITEMS.Add(new ItemCart
                    {
                        ID        = item.ID,
                        MOVIENAME = item.MOVIENAME,
                        SHOWTIME  = item.SHOWTIME,
                        SEAT      = item.SEAT,
                        COST      = item.COST,
                        Quantity  = 1
                    });
                }
                Session["cart"] = mvm;
            }
            return(View(mvm));
        }
Exemplo n.º 2
0
        public ActionResult ShoppingCart(itemCartViewModel mvm)
        {
            itemCartViewModel test = new itemCartViewModel();

            test = mvm;
            //TicketsDal dal = new TicketsDal();
            if (ModelState.IsValid)
            {
                return(View(mvm));
            }
            else
            {
                return(View("MovieGallery"));
            }
        }