Example #1
0
        public int ModaltoCart(string productid, string size, string color, string quantity)
        {
            var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie == null)
            {
                ViewBag.IsAuthenticated = false;
                return(1);
            }

            var ticket = FormsAuthentication.Decrypt(cookie.Value);

            ViewBag.IsAuthenticated = true;
            ViewData["UserName"]    = ticket.UserData;

            Procedure.Procedure procedure = new Procedure.Procedure();

            var ProductFormat = procedure.GetFormatIDByProductIDCS(int.Parse(productid), size, color);

            foreach (var item in ProductFormat)
            {
                productformatid = item.ProductFormatID;
                stock           = item.StockQuantity;
                image           = item.Image;
                productName     = item.ProductName;
                unitPrice       = item.UnitPrice;
            }

            var repeat = procedure.SearchRepeatCart(ticket.UserData, productformatid);

            if (repeat != null)
            {
                var isempty = 4;
                return(isempty);
            }
            else
            {
                if (int.Parse(quantity) <= stock)
                {
                    ShoppingCart shoppingCart = new ShoppingCart
                    {
                        MemberID        = ticket.UserData,
                        ProductFormatID = productformatid,
                        ProductID       = int.Parse(productid),
                        Quantity        = int.Parse(quantity),
                    };
                    var repository = new ShoppingCartRepository();
                    repository.Create(shoppingCart);
                    var isempty = 2;
                    CartIconNumber();
                    return(isempty);
                }
                else
                {
                    var isempty = 3;
                    return(isempty);
                }
            }
        }
Example #2
0
        public ActionResult Quantity(string color, string size, string productid)
        {
            int quantitynumber = 0;

            Procedure.Procedure procedure = new Procedure.Procedure();
            var ProductFormat             = procedure.GetFormatIDByProductIDCS(int.Parse(productid), size, color);

            foreach (var item in ProductFormat)
            {
                quantitynumber = item.StockQuantity;
            }
            ;
            if (ProductFormat == null)
            {
                ViewData["quantity"] = "0";
            }
            else
            {
                ViewData["quantity"] = quantitynumber.ToString();
            }
            return(PartialView());
        }