public IndexModel(SearchModel search) : this() { Query = search.Q; Category = search.Category; By = search.By; Page = search.Page; Size = search.Size; }
public ActionResult Index(SearchModel search) { var model = new IndexModel(search); var query = Db.Query<Quotes_Search.Result, Quotes_Search>() .If(model.HasQuery, q => q.Search(x => x.Content, model.Query, options: SearchOptions.And, escapeQueryOptions: EscapeQueryOptions.AllowPostfixWildcard)) .If(model.HasCategory, q => q.Where(x => x.Category == model.Category)) .If(model.HasBy, q => q.Where(x => x.By == model.By)) .OrderBy(x => x.By); model.Quotes = query .As<Quote>() .ToPagedList(model.Page, model.Size); if (model.CanGetSuggestions) model.Suggestions = query.Suggest(); return View(model); }