コード例 #1
0
        public async Task <Basket> GetBasket(ApplicationUser user, HttpRequest request)
        {
            var cookieBasket = request.Cookies["basket"];
            var basket       = new Basket();

            basket.Items = new List <BasketItem>();

            if (cookieBasket != null)
            {
                var backetIds = cookieBasket.Split(',').Select(int.Parse).ToList();
                foreach (var item in backetIds)
                {
                    var busketItem = BasketHelper.GetBusketItem(item);
                    busketItem.QuantityStock = await _catalogSvc.CheckStockAvailability(item);

                    basket.Items.Add(busketItem);
                }
            }

            return(basket);
        }