public async Task <ActionResult <IReadOnlyList <ProductToReturnDto> > > GetProducts() { var spec = new ProductWithCategoriesBrandsSpecification(); var products = await _productRepository.ListAsync(spec); return(Ok(_mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductToReturnDto> >(products))); }
public async Task <ActionResult <ProductToReturnDto> > GetProduct(int id) { var spec = new ProductWithCategoriesBrandsSpecification(id); var product = await _productRepository.GetEntityWithSpec(spec); if (product == null) { return(NotFound(new APIResponse(404))); } return(_mapper.Map <Product, ProductToReturnDto>(product)); }