Feature/respect encapsulation (#349)

* resolve osbsolete method

* put all properties as private, align unit test

* fix version of version in MD, add instruction to install ef tool

* fix url stored
This commit is contained in:
Cédric Michel
2020-02-03 20:47:59 +01:00
committed by GitHub
parent 288d827821
commit 3e228035c0
22 changed files with 162 additions and 99 deletions

View File

@@ -48,7 +48,7 @@ namespace Microsoft.eShopWeb.Web.Services
private async Task<BasketViewModel> CreateBasketForUser(string userId)
{
var basket = new Basket() { BuyerId = userId };
var basket = new Basket(userId);
await _basketRepository.AddAsync(basket);
return new BasketViewModel()

View File

@@ -17,15 +17,9 @@ namespace Microsoft.eShopWeb.Web.Services
public async Task UpdateCatalogItem(CatalogItemViewModel viewModel)
{
//Get existing CatalogItem
var existingCatalogItem = await _catalogItemRepository.GetByIdAsync(viewModel.Id);
//Build updated CatalogItem
var updatedCatalogItem = existingCatalogItem;
updatedCatalogItem.Name = viewModel.Name;
updatedCatalogItem.Price = viewModel.Price;
await _catalogItemRepository.UpdateAsync(updatedCatalogItem);
existingCatalogItem.Update(viewModel.Name, viewModel.Price);
await _catalogItemRepository.UpdateAsync(existingCatalogItem);
}
}
}

View File

@@ -48,19 +48,14 @@ namespace Microsoft.eShopWeb.Web.Services
// the implementation below using ForEach and Count. We need a List.
var itemsOnPage = await _itemRepository.ListAsync(filterPaginatedSpecification);
var totalItems = await _itemRepository.CountAsync(filterSpecification);
foreach (var itemOnPage in itemsOnPage)
{
itemOnPage.PictureUri = _uriComposer.ComposePicUri(itemOnPage.PictureUri);
}
var vm = new CatalogIndexViewModel()
{
CatalogItems = itemsOnPage.Select(i => new CatalogItemViewModel()
{
Id = i.Id,
Name = i.Name,
PictureUri = i.PictureUri,
PictureUri = _uriComposer.ComposePicUri(i.PictureUri),
Price = i.Price
}),
Brands = await GetBrands(),