Exemple #1
0
        public async Task <IReadOnlyList <ProductToReturnDto> > GetProducts()
        {
            var spec = new ProductWithsTypesAndBrandsSpecification();

            var products = await _productsRepo.ListAsync(spec);

            return(_mapper.Map <IReadOnlyList <ProductToReturnDto> >(products));
        }
Exemple #2
0
        public async Task <ActionResult <ProductToReturnDto> > GetProduct(int id)
        {
            var spec = new ProductWithsTypesAndBrandsSpecification(id);

            var product = await _productsRepo.GetEntityWithSpec(spec);

            if (product == null)
            {
                return(NotFound(new ApiResponse(StatusCodes.Status404NotFound)));
            }

            return(_mapper.Map <ProductToReturnDto>(product));
        }