Пример #1
0
        public ActionResult UndoPromo(string id1)
        {
            var idUser   = Security.GetIdUser(this);
            var usuario1 = User.Identity.Name;
            var products = (dynamic)null;
            var x        = (dynamic)null;

            try
            {
                ShoppingCart sh = new ShoppingCart();
                var          a  = (dynamic)null;
                if (usuario1 != "")
                {
                    var id = sh.User(usuario1);
                    a = sh.UndoPromoCode(id);
                }
                else
                {
                    a = a = sh.UndoPromoCode(idUser);
                }
                if (a == true)
                {
                    if (usuario1 != "")
                    {
                        var id = sh.User(usuario1);
                        products = sh.ProductsInCart(id);

                        foreach (var item in products)
                        {
                            x = new Framework.Libraies.ResultAllCart {
                                subtotal = item.subtotal, promocode = item.promocode, points = item.points, total = item.total, promocodeapp = item.promocodeapp, tax = item.tax
                            };
                        }
                        return(Json(new { x, JsonRequestBehavior.AllowGet }));
                    }
                    else
                    {
                        products = sh.ProductsInCart(idUser);
                        foreach (var item in products)
                        {
                            x = new Framework.Libraies.ResultAllCart {
                                subtotal = item.subtotal, promocode = item.promocode, points = item.points, total = item.total, promocodeapp = item.promocodeapp, tax = item.tax
                            };
                        }
                        return(Json(new { x, JsonRequestBehavior.AllowGet }));
                    }
                }
                else
                {
                    return(Json(new { Success = false }));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #2
0
        public ActionResult IncreaseProductFromCart(string idcart, int qty)
        {
            var idUser   = Security.GetIdUser(this);
            var usuario1 = User.Identity.Name;
            var products = (dynamic)null;
            var x        = (dynamic)null;

            try
            {
                var          a  = (dynamic)null;
                ShoppingCart sh = new ShoppingCart();
                if (usuario1 != "")
                {
                    var id = sh.User(usuario1);
                    a = sh.IncreaseProductFromCart(idcart, qty, id);
                }
                else
                {
                    a = sh.IncreaseProductFromCart(idcart, qty, idUser);
                }
                if (a != null)
                {
                    if (usuario1 != "")
                    {
                        var id = sh.User(usuario1);
                        products = sh.ProductsInCart(id);

                        foreach (var item in products)
                        {
                            x = new Framework.Libraies.ResultAllCart {
                                cart = item.cart, subtotal = item.subtotal, promocode = item.promocode, points = item.points, total = item.total, promocodeapp = item.promocodeapp, tax = item.tax
                            };
                        }
                        return(Json(new { x, qty, a, JsonRequestBehavior.AllowGet }));
                    }
                    else
                    {
                        products = sh.ProductsInCart(idUser);
                        foreach (var item in products)
                        {
                            x = new Framework.Libraies.ResultAllCart {
                                cart = item.cart, subtotal = item.subtotal, promocode = item.promocode, points = item.points, total = item.total, promocodeapp = item.promocodeapp, tax = item.tax
                            };
                        }
                        return(Json(new { x, qty, a, JsonRequestBehavior.AllowGet }));
                    }
                }
                else
                {
                    return(Json(new { error = false }));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #3
0
        //
        // GET: /ShoppingCart/
        public ActionResult Index()
        {
            string path = Request.Url.AbsolutePath;

            ViewBag.ReturnUrl = path;
            var          b        = (dynamic)null;
            ShoppingCart sh       = new ShoppingCart();
            var          idUser   = Security.GetIdUser(this);
            var          usuario1 = User.Identity.Name;
            var          pro      = (dynamic)null;
            var          valpromo = Session["PromoCode"];

            if (usuario1 != "")
            {
                var id = sh.User(usuario1);
                if (valpromo != null)//Si obtuvo el codigo de promocion desde la url
                {
                    sh.ValidatePromoCode(valpromo.ToString(), id);
                    Session["PromoCode"] = null;
                }
                sh.UpdateShoppingCart(id, idUser);
                pro = sh.ProductsInCart(id);
            }
            else
            {
                if (valpromo != null)//Si obtuvo el codigo de promocion desde la url
                {
                    sh.ValidatePromoCode(valpromo.ToString(), idUser);
                    Session["PromoCode"] = null;
                }
                pro = sh.ProductsInCart(idUser);
            }


            if (pro != null)
            {
                foreach (var item in pro)
                {
                    b = new Framework.Libraies.ResultAllCart {
                        cart = item.cart, subtotal = item.subtotal, promocode = item.promocode, points = item.points, total = item.total, promocodeapp = item.promocodeapp, tax = item.tax
                    };
                }
                return(View(b));
            }
            else
            {
                return(View());
            }
        }