public ActionResult <IEnumerable <CategoryDetailsViewModel> > Index(ISearchCategoryModel search) { var vm = this.manager.SearchProductCategory(search) .Select(CategoryDetailsViewModel.FromEntity(search.Language ?? base.AppSettings.DefaultLanguage)) .ToArray(); return(vm); }
public IQueryable <Category> SearchProductCategory(ISearchCategoryModel model) { var query = this.categoryRepo.All(); if (model == null) { return(query); } if (!string.IsNullOrWhiteSpace(model.Name)) { if (model.Language != null) { query = query.Where(c => c.Translations.Where(t => t.Language == model.Language && t.Name.Contains(model.Name)).Any()); } else { query = query.Where(c => c.Name.Contains(model.Name)); } } return(query); }