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:
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user