Пример #1
0
        public ProductsQueryResponse SearchInProducts(ProductsQueryRequest request)
        {
            var response = new ProductsQueryResponse();

            try
            {
                var products = _productRepository.SearchInProducts(request, request.Category);

                if (products == null)
                {
                    response.Message = ProductQueryMessage.NoResultFound;
                    return(response);
                }

                response.Products = Mapper.Map <PagingQueryResponse <Product>, PagingQueryResponse <ProductDto> >(products);
            }
            catch (Exception exception)
            {
                _logger.Error(exception.Message);
            }

            return(response);
        }
Пример #2
0
        public ProductsQueryResponse GetSpecialProducts(ProductsQueryRequest request)
        {
            var response = new ProductsQueryResponse();

            try
            {
                var products = _productRepository.GetSpecialProducts(request);

                if (products == null)
                {
                    response.Message = ProductQueryMessage.NoSpecialProductFound;
                    return(response);
                }

                response.Products = Mapper.Map <PagingQueryResponse <Product>, PagingQueryResponse <ProductDto> >(products);
            }
            catch (Exception exception)
            {
                _logger.Error(exception.Message);
                response.Message = QueryMessage.RetrievingFailed;
            }

            return(response);
        }
Пример #3
0
        public ProductsQueryResponse GetProductsByStore(ProductsQueryRequest request)
        {
            var response = new ProductsQueryResponse();

            try
            {
                var products = _productRepository.GetProductsByStore(request, request.StoreId);

                if (products == null)
                {
                    response.Message = ProductQueryMessage.NoProductFoundForTheStore;
                    return(response);
                }

                response.Products = Mapper.Map <PagingQueryResponse <Product>, PagingQueryResponse <ProductDto> >(products);
            }
            catch (Exception exception)
            {
                response.Failed = true;
                _logger.Log(exception.Message);
            }

            return(response);
        }
Пример #4
0
        public ProductsQueryResponse GetProductsByTag(ProductsQueryRequest request)
        {
            var response = new ProductsQueryResponse();

            try
            {
                var products = _productRepository.GetProductsByTag(request, request.Category, request.Tag);

                if (products == null)
                {
                    response.Message = ProductQueryMessage.NoProductFoundForTheTag;
                    return(response);
                }

                response.Products = Mapper.Map <PagingQueryResponse <Product>, PagingQueryResponse <ProductDto> >(products);
            }
            catch (Exception exception)
            {
                _logger.Error(exception.Message);
                response.Message = QueryMessage.RetrievingFailed;
            }

            return(response);
        }