public ActionResult Search([FromBody] ProductSearchDTO model)
        {
            Expression <Func <Product, bool> > filter = x => !string.IsNullOrWhiteSpace(x.Id);

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                filter = filter.AndOrCustom(
                    x => x.Name.ToUpper().Contains(model.Name.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }

            if (!string.IsNullOrWhiteSpace(model.ProviderName))
            {
                filter = filter.AndOrCustom(
                    x => x.Provider.Name.ToUpper().Contains(model.ProviderName.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }

            if (!string.IsNullOrWhiteSpace(model.ProductTypeDesc))
            {
                filter = filter.AndOrCustom(
                    x => x.ProductType.Description.ToUpper().Contains(model.ProductTypeDesc.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }

            var products = this.productService.Search(filter);
            var result   = this.mapper.Map <IEnumerable <ProductDTO> >(products).ToList();

            return(Ok(result));
        }
예제 #2
0
        public HttpResponseMessage GetProducts(ProductSearchDTO searchDto)
        {
            searchDto = searchDto ?? new ProductSearchDTO();
            var products = _productBL.GetProducts(searchDto);

            return(Request.CreateResponse(HttpStatusCode.OK, products));
        }
예제 #3
0
        public List <ProductDTO> GetProducts(ProductSearchDTO searchDto)
        {
            using (dbContext = new OMHRDModel())
            {
                var products = dbContext.Product_T.Where(x => (searchDto.SubCategoryId == 0 || x.SubCategoryId == searchDto.SubCategoryId) && (searchDto.CategoryId == 0 || x.ProductSubCategory_T.CategoryId == searchDto.CategoryId))
                               .Select(x => new ProductDTO
                {
                    Id               = x.Id,
                    Code             = x.Code,
                    Name             = x.Name,
                    HSN              = x.HSN,
                    ShortDescription = x.Description,
                    Description      = x.Description,
                    PriceList        = x.ProductPrice_T.Select(y => new ProductPriceDTO
                    {
                        Price     = y.Price,
                        Discount  = y.Discount,
                        Quantity  = y.Quantity,
                        SizeId    = y.ProductSizeId,
                        SizeCode  = y.ProductSize_T.Code,
                        ColorId   = y.ProductColorId,
                        ColorCode = y.ProductColorId == null ? y.ProductColor_T.Code : string.Empty
                    }).ToList()
                }).ToList();

                return(products);
            }
        }
예제 #4
0
        public async Task <IEnumerable <ProductDTO> > SearchProducts(ProductSearchDTO parameters)
        {
            IQueryable <Product> query = await _GetOrderSearchQuery(parameters);

            List <Product> products = query.ToList();

            return(_mapper.Map <IEnumerable <ProductDTO> >(products));
        }
예제 #5
0
        public HttpResponseMessage GetProductByCategory(int categoryId)
        {
            var searchDto = new ProductSearchDTO();

            searchDto.CategoryId = categoryId;
            var products = _productBL.GetProducts(searchDto);

            return(Request.CreateResponse(HttpStatusCode.OK, products));
        }
예제 #6
0
        private async Task <IQueryable <Product> > _GetOrderSearchQuery(ProductSearchDTO parameters)
        {
            IQueryable <Product> query = _queryBuilder.SetBaseProductInfo()
                                         .SetName(parameters.Name)
                                         .SetManufacturer(parameters.Manufacturer)
                                         .SetPrice(parameters.From, parameters.To)
                                         .SetCategory(parameters.CategoryId)
                                         .Build();

            return(query);
        }
예제 #7
0
        public ActionResult Search([FromBody] ProductSearchDTO model)
        {
            Expression <Func <Product, bool> > filter = x => !string.IsNullOrWhiteSpace(x.Id);

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                filter = filter.AndOrCustom(
                    x => x.Name.ToUpper().Contains(model.Name.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }

            var products = this.service.Search(filter);

            return(Ok(products));
        }
예제 #8
0
 public ProductModel(ProductSearchDTO dto)
 {
     ID          = dto.ID;
     Code        = dto.Code;
     Title       = dto.ProductTitle;
     Description = dto.Description;
     Category    = new CategoryModel
     {
         ID    = dto.CategoryID,
         Title = dto.CategoryTitle,
     };
     Price        = dto.Price;
     ImageURL     = dto.ImageURL;
     RecordStatus = dto.RecordStatus;
 }
예제 #9
0
        public ActionResult Search([FromBody] ProductSearchDTO model)
        {
            Expression <Func <Product, bool> > filter = x => !string.IsNullOrWhiteSpace(x.Id);

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                filter = filter.AndOrCustom(
                    x => x.Name.ToUpper().Contains(model.Name.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }

            var products = this.service.Search(filter);

            return(Ok(new { Success = true, Message = "List of all Products",
                            Products = this.mapper.Map <IEnumerable <ProductDTO> >(products).ToList() }));
        }
        public ActionResult <ProductDTO> Search([FromBody] ProductSearchDTO model)
        {
            Expression <Func <Product, bool> > filter = x => !string.IsNullOrWhiteSpace(x.Id);

            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                filter = filter.AndOrCustom(
                    x => x.Name.ToUpper().Contains(model.Name.ToUpper()),
                    model.Condition.Equals(ActionDto.AND));
            }
            try{
                var products = this.serviceProduct.Search(filter);
                return(Ok(this.mapper.Map <IEnumerable <ProductDTO> >(products).ToList()));
            }
            catch {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
예제 #11
0
        public List <ProductDTO> GetProducts(ProductSearchDTO searchDto)
        {
            var products = _productRep.GetProducts(searchDto);

            return(products);
        }
예제 #12
0
 public async Task <IActionResult> Search([FromQuery] ProductSearchDTO parameters)
 {
     return(Ok(await _productService.SearchProducts(parameters)));
 }