Ejemplo n.º 1
0
        public PartialViewResult ListCart()
        {
            var codeCookie = HttpContext.Request.Cookies["addtocart"];
            var list       = new List <ShopProductCartItem>();

            if (codeCookie != null)
            {
                var temp = codeCookie.Value;
                var lst  = new JavaScriptSerializer().Deserialize <List <ShopProductDetailCartItem> >(temp);
                list = (from item in lst
                        let model = _productDa.GetProductCart(item.ProductId ?? 0, item.SizeID ?? 0)
                                    where model != null
                                    select new ShopProductCartItem
                {
                    Name = model.Name,
                    ColorName = model.ColorName,
                    ColorCode = model.ColorCode,
                    UrlPicture = model.UrlPicture,
                    ID = model.ID,
                    Size = model.Size,
                    Price = model.Price,
                    Total = model.Price * item.Quantity,
                    Quantity = item.Quantity,
                    ProductId = item.ProductId,
                    SizeId = item.SizeID,
                    ShopID = item.ShopID
                }).ToList();
            }
            return(PartialView(list));
        }