Пример #1
0
        public ProductListResponse ListResponse(ProductListRequest request)
        {
            var products = _productRepository.Get(request.Page, request.Term, request.CategoryFilterId).ToList();

            return(new ProductListResponse()
            {
                Values = products.Select(x => ProductDtoBuilder.ToDto(x)).ToList(),
                Total = _productRepository.Get(title: request.Term, categoryFilterId: request.CategoryFilterId).Count()
            });
        }
Пример #2
0
        public ProductDto GetById(Guid id)
        {
            var product = _productRepository.GetById(id);

            if (product == null)
            {
                return(null);
            }

            return(ProductDtoBuilder.ToDto(product));
        }
Пример #3
0
        public bool Add(ProductDto dto)
        {
            var product = ProductDtoBuilder.ToEntity(dto);

            return(_productRepository.Add(product) == 1);
        }