public List <ProductDto> GetAllProductDetailsByFilter(ProductDetailFilterDto filterDto) { using (UzmanContext context = new UzmanContext()) { var filterExpression = filterDto.GetFilterExpression <Product>(); var result = from product in filterExpression == null ? context.Products : context.Products.Where(filterExpression) join category in context.Categories on product.CategoryId equals category.Id join brand in context.Brands on product.BrandId equals brand.Id select new ProductDto() { Id = product.Id, CategoryId = product.CategoryId, CategoryName = category.Name, BrandId = product.BrandId, BrandName = brand.Name, Name = product.Name, Code = product.Code, Price = product.Price, Images = (from i in context.ProductImages where i.ProductId == product.Id select i.ImagePath) .ToList(), CreateDate = product.CreateDate, Active = product.Active }; return(result.ToList()); } }
public IActionResult GetAllProductDetailsByFilter([FromQuery] ProductDetailFilterDto filterDto) { var result = _productService.GetAllProductDetailsFilter(filterDto); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public IDataResult <List <ProductDto> > GetAllProductDetailsFilter(ProductDetailFilterDto filterDto) { return(new SuccessDataResult <List <ProductDto> >(_productDal.GetAllProductDetailsByFilter(filterDto))); }