public IActionResult Index(int page = 1, string search = null) { //TODO Stworzyć formularz wyszukiwarkę osoby i przerzucić wyświetlenie osób na osobny widok int pagemax = 0; do { pagemax++; }while (SourceManager.Get(pagemax, 4).Any()); int pagemaxsearch = 0; do { pagemaxsearch++; }while (SourceManager.GetByName(search, pagemax, 4).Any()); ViewBag.Search = search; ViewBag.pagemax = pagemax; ViewBag.pagemaxsearch = pagemaxsearch; ViewBag.page = page; if (search != null) { return(View(SourceManager.GetByName(search, page, 4))); } else { return(View(SourceManager.Get(page, 4))); } }
public IActionResult Search(string name, int page = 1) { if (string.IsNullOrEmpty(name)) { TempData["Info"] = $"Enter full or part of name"; return(Redirect("/Person/Index")); } List <PersonModel> personsPag = SourceManager.GetByName(name, out int num, page); if (num == 0) { TempData["Info"] = $"No results"; return(Redirect("/Person/Index")); } ViewBag.Page = page; ViewBag.Rows = (int)Math.Ceiling(num / 3.0); ViewBag.Name = name; return(View(personsPag)); }