public ActionResult <IEnumerable <ProductColorDetailsViewModel> > Index(ISearchColorModel search) { var vm = this.manager.SearchProductColor(search) .Select(ProductColorDetailsViewModel.FromEntity) .ToArray(); return(vm); }
public IQueryable <ProductColor> SearchProductColor(ISearchColorModel model) { var query = this.colorRepo.All(); if (model == null) { return(query); } if (!string.IsNullOrWhiteSpace(model.Name)) { query = query.Where(c => c.Name.Contains(model.Name)); } if (!string.IsNullOrWhiteSpace(model.Value)) { query = query.Where(c => c.Value.Contains(model.Value)); } return(query); }