コード例 #1
0
        async Task <BasketIndexViewModel> GetCurrentUserBasket()
        {
            string userId = _userService.GetUserName(HttpContext, Request.Cookies, Response.Cookies);

            BasketIndexViewModel b = await _basketService.GetOrCreateBasketForUser(userId);

            return(b);
        }
コード例 #2
0
        private async Task <BasketIndexViewModel> GetBasketViewModelAsync()
        {
            if (_signInManager.IsSignedIn(HttpContext.User))
            {
                return(await _basketService.GetOrCreateBasketForUser(User.Identity.Name));
            }
            string anonymousId = GetBasketIdFromCookie();

            if (anonymousId == null)
            {
                return new BasketIndexViewModel()
                       {
                           BasketItems = new System.Collections.Generic.List <BasketItemViewModel>()
                       }
            }
            ;
            return(await _basketService.GetOrCreateBasketForUser(anonymousId));
        }