public ActionResult Admin(SearchCtx ctx) { List<Vehicle> found = garage.Search(ctx).ToList(); if (found.Count == 0) return RedirectToAction("NotFound"); TempData["vehicles"] = found; return RedirectToAction("List"); }
private Minimatcher GetMinimatcher(SearchCtx ctx) { if (string.IsNullOrEmpty(ctx.Searchstring)) { return(null); } if (!(ctx.Searchstring.Contains('*') || ctx.Searchstring.Contains('?'))) { ctx.Searchstring = "*" + ctx.Searchstring + "*"; } return(new Minimatcher(ctx.Searchstring)); }
public Vehicle[] Search(SearchCtx ctx) { Minimatcher mm = GetMinimatcher(ctx); var vehicles = JoinVehicles(); var typesById = TypesById(); var found = vehicles .Where(a => ctx.SelectedType == "1" || a.Typename == typesById[ctx.SelectedType]) .Where(a => !ctx.OnlyToday || DateTime.Now.Day == a.checkInDate.Day) .Where(a => mm == null || (a.RegNr != null && mm.IsMatch(a.RegNr)) || (a.OwnerName != null && mm.IsMatch(a.OwnerName))); return(found.ToArray()); }
public ActionResult Search(SearchCtx ctx) { TempData["vehicles"] = garage.Search(ctx).ToList<Vehicle>(); return List(); }
public ActionResult Admin(SearchCtx ctx, int page = 1) { return ShowAdmin(ctx, page); }
private ActionResult ShowAdmin(SearchCtx ctx, int page = 1) { if (ctx == null) ctx = (SearchCtx)TempData["SearchCtx"]; if (ctx == null) ctx = new SearchCtx(); ctx.TypesById = garage.TypesById(); if (ctx.Results.Count == 0) { ctx.Results = garage.Search(ctx).ToList(); } ctx.PagedResults = ctx.Results.ToPagedList(page, 10); TempData["vehicles"] = ctx.Results; TempData["SearchCtx"] = ctx; return View(ctx); }
public ActionResult Sort(string sortOrder) { SearchCtx ctx = (SearchCtx)TempData["SearchCtx"]; if (ctx == null) ctx = new SearchCtx(); ctx.Sort(sortOrder); TempData["SearchCtx"] = ctx; TempData["vehicles"] = ctx.Results; return RedirectToAction("Admin", new { page = 1 }); }