async Task <BasketIndexViewModel> GetCurrentUserBasket() { string userId = _userService.GetUserName(HttpContext, Request.Cookies, Response.Cookies); BasketIndexViewModel b = await _basketService.GetOrCreateBasketForUser(userId); return(b); }
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)); }