Example #1
0
        // POST: CartsItem/Edit
        public ActionResult Edit(CartItem cartItem)
        {
            var cp = new CartItemProcess();

            cp.Edit(cartItem);
            return(RedirectToAction("Index"));
        }
Example #2
0
        // GET: CartsItem/Delete
        public ActionResult Delete(int id)
        {
            var cp = new CartItemProcess();

            cp.Delete(id);
            return(RedirectToAction("Index"));
        }
Example #3
0
        // GET: CartsItem/Edit
        public ActionResult Edit(int id)
        {
            var cp       = new CartItemProcess();
            var cartItem = cp.Find(id);

            return(View(cartItem));
        }
Example #4
0
        // GET: CartItems/CartItem
        public ActionResult Index()
        {
            var cp    = new CartItemProcess();
            var lista = cp.SelectList();

            return(View(lista));
        }
Example #5
0
        // POST: CartsItem/Create
        public ActionResult Create(CartItem cartItem)
        {
            var cp = new CartItemProcess();

            cp.Insert(cartItem);
            return(RedirectToAction("Index"));
        }
Example #6
0
        // POST: CartsItem/Create
        public ActionResult Create(CartItem cartItem)
        {
            var cp = new CartItemProcess();

            cp.Insert(cartItem);
            return(RedirectToAction("ProductList", "Product", new { area = "Products" }));
        }
Example #7
0
        public ActionResult Index()
        {
            var cookie = Request.Cookies[".AspNet.ApplicationCookie"].Value;
            var cp     = new CartProcess();
            var cart   = cp.Cookie(cookie);

            if (cart == null)
            {
                //VER QUE HACER CUANDO EL CARRITO NO EXISTE
                cart    = new Cart();
                cart.Id = 0;
            }


            var cip           = new CartItemProcess();
            var lista         = cip.FindByCartId(cart.Id);
            var total         = 0.0;
            var parcial       = 0.0;
            var CantidadTotal = 0;

            foreach (CartItem item in lista)
            {
                parcial       = item.Price * item.Quantity;
                total         = total + parcial;
                CantidadTotal = CantidadTotal + item.Quantity;
            }
            ViewBag.Cantidad = CantidadTotal;
            ViewBag.total    = total;
            ViewBag.cartid   = cart.Id;
            return(View(lista));
        }
Example #8
0
        // GET: CartsItem/Edit
        public ActionResult Edit(int id)
        {
            var cip      = new CartItemProcess();
            var cartItem = cip.Find(id);

            var cp    = new CartProcess();
            var lista = cp.SelectList();

            ViewData["Cart"] = lista;

            return(View(cartItem));
        }
Example #9
0
        // GET: Orders/Create
        public ActionResult Create(int cartid)
        {
            //Creamos una nueva Order
            var orderprecargada = new Order();

            //Traemos el ID del cliente por el aspnetuser
            var aspuser = User.Identity.GetUserId();
            var cp      = new ClientProcess();
            var client  = cp.FindByASPUSER(aspuser);

            //Traemos todos los CartItem por el CartId
            var cip   = new CartItemProcess();
            var lista = cip.FindByCartId(cartid);
            var total = 0.0;
            var cant  = 0;

            foreach (CartItem item in lista)
            {
                item.Price = item.Price * item.Quantity;
                total      = total + item.Price;
                cant       = cant + 1;
            }

            //Completamos la Order con la info del Cart

            orderprecargada.ClientId    = client.Id;
            orderprecargada.OrderDate   = DateTime.Now;
            orderprecargada.TotalPrice  = total;
            orderprecargada.State       = 1;
            orderprecargada.OrderNumber = cartid;
            orderprecargada.ItemCount   = cant;

            //Guardamos el OrderNumber en una Cookie
            Response.Cookies["OrderNumber"].Value = cartid.ToString();


            //Insertamos la nueva Order
            var op           = new OrderProcess();
            var ordercargada = new Order();

            ordercargada = op.Insert(orderprecargada);
            //op.Insert(orderprecargada);

            return(RedirectToAction("Index", "OrderDetail", new { area = "OrderDetails" }));
        }
Example #10
0
        //// GET: Products/Product
        //[Authorize]
        public ActionResult ProductList(int Category = -1)
        {
            if (User.Identity.IsAuthenticated == true)
            {
                var cookie = Request.Cookies[".AspNet.ApplicationCookie"].Value;
                var cp     = new CartProcess();
                var cart   = cp.Cookie(cookie);
                if (cart == null)
                {
                    ViewBag.Cantidad = 0;
                }

                else
                {
                    var cip           = new CartItemProcess();
                    var listaItems    = cip.FindByCartId(cart.Id);
                    var CantidadTotal = 0;
                    foreach (CartItem item in listaItems)
                    {
                        CantidadTotal = CantidadTotal + item.Quantity;
                    }
                    ViewBag.Cantidad = CantidadTotal;
                }
            }
            else
            {
                ViewBag.Cantidad = 0;
            }

            var cp2 = new CategoryProcess();
            var pp  = new ProductProcess();

            ViewData["Category"] = cp2.SelectList();
            var lista = new List <Product>();


            if (Category > -1)
            {
                lista = pp.SelectByCat(Category);
            }

            return(View(lista));
        }
Example #11
0
        //public ProductManagement ProductManagement { get; set; }
        //// GET: Cart

        public CartController()
        {
            process         = new CartProcess();
            processproduct  = new ProductProcess();
            processcartitem = new CartItemProcess();
        }