// GET: Products public async Task <IActionResult> Index() { var products = await _productsService.SearchAsync(); var productsViewModels = products.Select(x => _productMapper.MapToViewModel(x)); return(View(productsViewModels)); }
public IEnumerable <ProductViewModel> GetMappedProducts(Guid clientId) { IClient client = clientRepository.Get(clientId); IEnumerable <IProduct> products = productRepository.GetClientProducts(client); IProductMapper productMapper = mapperFactory.CreateMapper <IProductMapper, IProduct>(products); IEnumerable <IProduct> processedProducts = productMapper.ApplyTVA(products); IProductViewModelMapper viewModelMapper = mapperFactory.CreateMapper <IProductViewModelMapper, IProduct>(processedProducts); IEnumerable <ProductViewModel> viewModel = viewModelMapper.MapToViewModel(processedProducts); return(viewModel); }