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)); }
public HttpResponseMessage GetProducts(ProductSearchDTO searchDto) { searchDto = searchDto ?? new ProductSearchDTO(); var products = _productBL.GetProducts(searchDto); return(Request.CreateResponse(HttpStatusCode.OK, products)); }
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); } }
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)); }
public HttpResponseMessage GetProductByCategory(int categoryId) { var searchDto = new ProductSearchDTO(); searchDto.CategoryId = categoryId; var products = _productBL.GetProducts(searchDto); return(Request.CreateResponse(HttpStatusCode.OK, products)); }
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); }
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)); }
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; }
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)); } }
public List <ProductDTO> GetProducts(ProductSearchDTO searchDto) { var products = _productRep.GetProducts(searchDto); return(products); }
public async Task <IActionResult> Search([FromQuery] ProductSearchDTO parameters) { return(Ok(await _productService.SearchProducts(parameters))); }