Ejemplo n.º 1
0
        public ActionResult CartSummary()
        {
            var cart = Carrito.GetCart(this.HttpContext);

            ViewData["CartCount"] = cart.GetCount();
            return(PartialView("CartSummary"));
        }
Ejemplo n.º 2
0
        private void MigrateShoppingCart(string UserName)
        {
            //Associate shopping cart items with logged-in user
            var cart = Carrito.GetCart(this.HttpContext);

            cart.MigrateCart(UserName);
            Session[Carrito.CartSessionKey] = UserName;
        }
Ejemplo n.º 3
0
        public ActionResult AddressAndPayment(Orden order)
        {
            var cart = Carrito.GetCart(this.HttpContext);

            //var orderTotal = cart.GetTotal();

            using (BDTestEntities1 db = new BDTestEntities1())
            {
                order.Total = cart.GetTotal();

                db.Orden.Add(order);
                db.SaveChanges();

                //cart.CreateOrder(order);
                cart.EmptyCart();

                return(RedirectToAction("Complete", new { id = order.OrderId }));
            }

            /*var order = new Orden();
             * TryUpdateModel(order);
             *
             * //try
             * //{
             *
             * try
             * {
             *  storeDB.Orden.Add(order);
             *  storeDB.SaveChanges();
             * } catch(DbEntityValidationException dbEx)
             * {
             *  foreach(var validationErrors in dbEx.EntityValidationErrors)
             *  {
             *      foreach (var validationError in validationErrors.ValidationErrors)
             *      {
             *          Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             *      }
             *  }
             * }
             *
             *
             *  var cart = Carrito.GetCart(this.HttpContext);
             *  cart.CreateOrder(order);
             *
             *  //storeDB.SaveChanges();
             *
             *  return RedirectToAction("Complete", new { id = order.OrderId });
             * }
             * catch
             * {
             *  //Invalid
             *  return View(order);
             * }*/
        }
Ejemplo n.º 4
0
        //
        // GET: /Store/AddToCart/id
        public ActionResult AddToCart(int id)
        {
            //retrieve producto from database
            var addedProd = storeDB.Producto.Single(producto => producto.ProductID == id);

            //añadir al carrito
            var cart = Carrito.GetCart(this.HttpContext);

            cart.AddToCart(addedProd);
            //back to main store
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        //
        // GET: /Carrito/

        public ActionResult Index()
        {
            var cart = Carrito.GetCart(this.HttpContext);

            //set up viewmodel
            var viewModel = new ShoppingCartViewModel
            {
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal()
            };

            return(View(viewModel));
        }
Ejemplo n.º 6
0
        public ActionResult RemoveFromCart(int id)
        {
            //eliminar art del carrito
            var cart = Carrito.GetCart(this.HttpContext);

            //para la confirmación de que hay que eliminar el artículo
            string prodName = storeDB.Cart.Single(item => item.RecordID == id).ProductName;

            //remove from cart
            int itemCount = cart.RemoveFromCart(id);

            //display confirmation message
            var results = new ShoppingCartRemoveViewModel
            {
                Mensaje   = Server.HtmlEncode(prodName) + " ha sido eliminado de su carro de compras.",
                CartTotal = cart.GetTotal(),
                CartCount = cart.GetCount(),
                ItemCount = itemCount,
                DeleteId  = id
            };

            return(Json(results));
        }