Esempio n. 1
0
        public async Task <CartViewModel> GetOrCreateCartForUser(string userName)
        {
            var cartSpec = new CartSpec(userName);
            var cart     = (await _cartRepository.ListAsync(cartSpec)).FirstOrDefault();

            if (cart == null)
            {
                return(await CreateCartForUser(userName));
            }
            return(CreateViewModelFromCart(cart));
        }
Esempio n. 2
0
        public async Task <int> GetCartProductCountAsync(string userName)
        {
            var cartSpec = new CartSpec(userName);
            var cart     = (await _CartRepository.ListAsync(cartSpec)).FirstOrDefault();

            if (cart == null)
            {
                return(0);
            }
            int count = cart.Items.Sum(i => i.UnitQuantity);

            return(count);
        }