Refactoring Services (#61)

* Refactoring ViewModels into Razor Pages models

* Cleaning up Basket viewcomponent

* Refactoring services.
Fixed bug in basket item counter.
This commit is contained in:
Steve Smith
2017-10-23 10:52:33 -04:00
committed by GitHub
parent dea73a5f5e
commit 16d81ae450
28 changed files with 218 additions and 230 deletions

View File

@@ -5,9 +5,8 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Infrastructure.Identity;
using System;
using Web;
using Microsoft.AspNetCore.Authentication;
using Microsoft.eShopWeb.Interfaces;
using ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.Controllers
{

View File

@@ -22,8 +22,10 @@ namespace Microsoft.eShopWeb.Controllers
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IAppLogger<BasketController> _logger;
private readonly IOrderService _orderService;
private readonly IBasketViewModelService _basketViewModelService;
public BasketController(IBasketService basketService,
IBasketViewModelService basketViewModelService,
IOrderService orderService,
IUriComposer uriComposer,
SignInManager<ApplicationUser> signInManager,
@@ -34,6 +36,7 @@ namespace Microsoft.eShopWeb.Controllers
_signInManager = signInManager;
_logger = logger;
_orderService = orderService;
_basketViewModelService = basketViewModelService;
}
[HttpGet]
@@ -87,10 +90,10 @@ namespace Microsoft.eShopWeb.Controllers
{
if (_signInManager.IsSignedIn(HttpContext.User))
{
return await _basketService.GetOrCreateBasketForUser(User.Identity.Name);
return await _basketViewModelService.GetOrCreateBasketForUser(User.Identity.Name);
}
string anonymousId = GetOrSetBasketCookie();
return await _basketService.GetOrCreateBasketForUser(anonymousId);
return await _basketViewModelService.GetOrCreateBasketForUser(anonymousId);
}
private string GetOrSetBasketCookie()