// GET: Dashboard/Vacancies public async Task <IActionResult> Index( string sortOrder, string currentFilter, string searchString, int?page, bool showDisabled = false) { ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; ViewBag.ShowDisabled = showDisabled; var cases = _vacancyRepository.GetAll().Where(c => !c.Deleted && (c.Enabled || showDisabled) && (string.IsNullOrEmpty(searchString) || c.FunctionDescription.Contains(searchString))); switch (sortOrder) { case "name_desc": cases = cases.OrderByDescending(c => c.FunctionDescription); break; case "Date": cases = cases.OrderBy(c => c.VacancySince); break; case "date_desc": cases = cases.OrderByDescending(c => c.VacancySince); break; default: cases = cases.OrderBy(c => c.FunctionDescription); break; } return(View(await PaginatedList <Vacancy> .Create(cases.AsQueryable(), page ?? 1, 5))); }
// GET: /<controller>/ public async Task <IActionResult> Index() { return(View(await _vacancyRepository.GetAll().Where(v => !v.Deleted && v.Enabled) .OrderByDescending(v => v.VacancySince).Take(3).ToListAsync())); }