Files
eShopOnWeb/src/Web/Services/CatalogItemViewModelService.cs
Cédric Michel 3e228035c0 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
2020-02-03 12:47:59 -07:00

26 lines
950 B
C#

using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.Web.Interfaces;
using Microsoft.eShopWeb.Web.ViewModels;
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.Web.Services
{
public class CatalogItemViewModelService : ICatalogItemViewModelService
{
private readonly IAsyncRepository<CatalogItem> _catalogItemRepository;
public CatalogItemViewModelService(IAsyncRepository<CatalogItem> catalogItemRepository)
{
_catalogItemRepository = catalogItemRepository;
}
public async Task UpdateCatalogItem(CatalogItemViewModel viewModel)
{
var existingCatalogItem = await _catalogItemRepository.GetByIdAsync(viewModel.Id);
existingCatalogItem.Update(viewModel.Name, viewModel.Price);
await _catalogItemRepository.UpdateAsync(existingCatalogItem);
}
}
}