public IEnumerable <ProductDto> GetProducts(ProiductFilter filter) { var query = _db.Products.Include("Brand").Include("Section").AsQueryable(); if (filter.BrandId.HasValue) { query = query.Where(x => x.BrandId.HasValue && x.BrandId.Equals(filter.BrandId)); } if (filter.SectionId.HasValue) { query = query.Where(x => x.SectionId.Equals(filter.SectionId)); } return(query.Select(x => new ProductDto { Brand = x.BrandId.HasValue ? new BrandDto { Id = x.Brand.Id, Name = x.Brand.Name, Order = x.Brand.Order } : null, Section = new SectionDto() { Id = x.SectionId, Name = x.Section.Name }, Id = x.Id, Order = x.Order, Name = x.Name, ImageUrl = x.ImageUrl, Price = x.Price }).ToList()); }
public IEnumerable <ProductDto> GetProducts(ProiductFilter filter) { var url = $"{ServiceAddress}"; var responce = Post(url, filter); var result = responce.Content.ReadAsAsync <IEnumerable <ProductDto> >().Result; return(result); }
public IEnumerable <ProductDto> GetProducts([FromBody] ProiductFilter filter) { return(_productData.GetProducts(filter)); }