public IQueryable <Product> SearchProduct(SearchProductOptions options) { if (options == null) { return(null); } var query = context_ .Set <Product>() .AsQueryable(); if (options.Category != null) { query = query.Where(p => p.Category == options.Category); } if (options.ProductId != null) { query = query.Where(p => p.ProductId == options.ProductId.Value); } if (options.PriceFrom != null) { query = query.Where(p => p.Price > options.PriceTo && p.Price < options.PriceTo); } query = query.Take(500); return(query); }
public IQueryable <Product> SearchProduct(SearchProductOptions options) { if (options == null) { return(null); } var query = context .Set <Product>() .AsQueryable(); if (options.Description != null) { query = query.Where(c => c.Description. Contains(options.Description).ToString() == options.Description); } if (options.PriceMax != null && options.PriceMax > 0) { query = query.Where(c => c.Price <= options.PriceMax.Value); } if (options.PriceMin != null && options.PriceMin > 0) { query = query.Where(c => c.Price >= options.PriceMin.Value); } return(query); }
public IQueryable <Product> SearchProducts(SearchProductOptions options) { if (options == null) { return(null); } var query = context_ .Set <Product>() .AsQueryable(); if (!string.IsNullOrWhiteSpace(options.ProductId)) { query = query.Where(p => p.ProductId == options.ProductId); } if (options.PriceFrom != null) { query = query.Where(p => p.Price >= options.PriceFrom); } if (options.PriceTo != null) { query = query.Where(p => p.Price <= options.PriceTo); } if (options.Category != null) { query = query.Where(p => p.Category == options.Category); } query = query.Take(500); return(query); }
public IQueryable <Product> SearchProducts(SearchProductOptions options) { if (options == null) { return(null); } var query = context_ .Set <Product>() .AsQueryable(); if (!string.IsNullOrWhiteSpace(options.ProductId)) { query = query.Where(c => c.ProductId == options.ProductId); } if (!string.IsNullOrWhiteSpace(options.Name)) { query = query.Where(c => c.Name == options.Name); } if (!string.IsNullOrWhiteSpace(options.Description)) { query = query.Where(c => c.Description.Contains(options.Description)); } if (options.PriceFrom >= 0) { query = query.Where(c => c.Price >= options.PriceFrom); } if (options.PriceTo >= 0) { query = query.Where(c => c.Price <= options.PriceTo); } if (options.CreatedFrom != null) { query = query.Where(c => c.Created <= options.CreatedFrom); } if (options.CreatedTo != null) { query = query.Where(c => c.Created <= options.CreatedTo); } if (options.Category >= 0) { query = query.Where(c => c.Category == options.Category); } query = query.Take(500); return(query); }
public IQueryable<Product> SearchProducts( SearchProductOptions options) { if (options == null) { return null; } var query = context .Set<Product>() .AsQueryable(); if (!string.IsNullOrWhiteSpace(options.ProductId)) { query = query.Where(prod => prod.ProductId == options.ProductId); } if (!string.IsNullOrWhiteSpace(options.Description)) { query = query.Where(prod => prod.Description == options.Description); } if (!string.IsNullOrWhiteSpace(options.Name)) { query = query.Where(prod => prod.Name == options.Name); } if (options.PriceFrom != null) { query = query.Where(prod => prod.Price >= options.PriceFrom); } if (options.PriceTo != null) { query = query.Where(prod => prod.Price <= options.PriceTo); } if (options.Category != null) { query = query.Where(prod => prod.Category == options.Category); } query = query.Take(500); return query; }
public IQueryable <Product> SearchProducts(SearchProductOptions options) { if (options == null) { return(null); } var query = context_ .Set <Product>() .AsQueryable(); if (!string.IsNullOrWhiteSpace(options.ProductId)) { query = query.Where(c => c.ProductId == options.ProductId); } if (!string.IsNullOrWhiteSpace(options.Name)) { query = query.Where(c => c.Name.Contains(options.Name.Trim())); } if (!string.IsNullOrWhiteSpace(options.Description)) { query = query.Where(c => c.Description.Contains(options.Description.Trim())); } if (options.Category != null) { query = query.Where(c => c.Category == options.Category); } if (options.MinPrice != null) { query = query.Where(c => c.Price >= options.MinPrice); } if (options.MaxPrice != null) { query = query.Where(c => c.Price <= options.MinPrice); } query = query.Take(500); return(query); }
public List <Product> Search(SearchProductOptions options) { if (options == null) { return(null); } var query = context .Set <Product>() .AsQueryable(); if (options.Id != null) { query = query.Where( p => p.Id == options.Id); } if (options.Name != null) { query = query.Where(c => c.Name.Contains(options.Name)); } if (options.Description != null) { query = query.Where(p => p.Description.Contains(options.Description)); } if (options.MinValue != 0) { query = query.Where(p => p.Price >= options.MinValue); } if (options.MaxValue != 0) { query = query.Where(p => p.Price <= options.MaxValue); } return(query.ToList()); }
public IQueryable <Product> SearchProduct(SearchProductOptions options) { if (options == null) { return(null); } var query = context_ .Set <Product>() .AsQueryable(); if (!string.IsNullOrWhiteSpace(options.Name)) { query = query.Where(p => p.Name == options.Name); } if (!string.IsNullOrWhiteSpace(options.Description)) { query = query.Where(p => p.Description == options.Description); } if (options.ProductId != null) { query = query.Where(p => p.ProductId == options.ProductId); } if (options.PriceTo != null) { query = query.Where(p => p.Price <= options.PriceTo); } if (options.PriceFrom != null) { query = query.Where(p => p.Price >= options.PriceFrom); } return(query); }
/// <summary> /// Return the product that has an id equals to id /// </summary> /// <param name="id"></param> /// <returns></returns> public Product GetProductById(string id) { if (string.IsNullOrWhiteSpace(id)) { return(null); } SearchProductOptions options = new SearchProductOptions() { Id = id }; List <Product> product = SearchProduct(options); if (product.Count < 1) { return(null); } else { return(product[0]); } }
public List <Product> SearchProduct(SearchProductOptions options) { List <Product> returnList = new List <Product>(); if (options == null) { return(null); } if (!string.IsNullOrWhiteSpace(options.Id)) { var temp = context_ .Set <Product>() .SingleOrDefault(p => p.Id == options.Id); if (temp != default(Product)) { returnList.Add(temp); return(returnList); } } if (!string.IsNullOrWhiteSpace(options.Description)) { returnList .AddRange( context_ .Set <Product>() .Where(p => p.Description .Contains(options.Description)) .ToList()); } if (options.Discount > 0 && options.Discount < 100) { returnList.AddRange(context_ .Set <Product>() .Where(p => p.Discount == options.Discount) .ToList()); } if (!string.IsNullOrWhiteSpace(options.Name)) { returnList.AddRange(context_ .Set <Product>() .Where(s => s.Name == options.Name) .ToList()); } if (options.Price > 0) { returnList.AddRange(context_ .Set <Product>() .Where(p => p.Price == options.Price) .ToList()); } if (options.Category != ProductCategory.Invalid) { returnList.AddRange(context_ .Set <Product>() .Where(p => p.Category == options.Category) .ToList()); } returnList = returnList.Distinct().ToList(); return(returnList); }
public IQueryable <Product> SearchProduct(SearchProductOptions options) { return(prodServ.SearchProduct(options)); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <returns></returns> public List <Product> SearchProduct(SearchProductOptions options) { if (options == null) { return(default);