public ActionResult Index(int?page, string searchString = null) { ViewBag.DirectorFilter = searchString; var directors = _directorDataProvider.GetDirectorBySearchString(searchString, ApplicationUser); var pageSize = 5; var pageNumber = (page ?? 1); var actorsListViewModel = new DirectorListViewModel() { DirectorsList = directors.ToPagedList(pageNumber, pageSize) }; return(View(actorsListViewModel)); }
public ViewResult ViewDirectors(string searchString, string currentFilter, string sortOrder, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = string.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.ActorsFilter = searchString; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; var sortOrderEnum = SortOrder.Asc; var sortParamEnum = SortParam.Name; if (sortOrder == "name_desc") { sortOrderEnum = SortOrder.Desc; } else if (sortOrder == "date_desc") { sortOrderEnum = SortOrder.Desc; sortParamEnum = SortParam.Date; } else if (sortOrder == "Date") { sortParamEnum = SortParam.Date; } var directors = _directorDataProvider.GetDirectorBySearchString(searchString, sortParamEnum, sortOrderEnum); if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.ActorsFilter = searchString; var pageSize = 10; var pageNumber = (page ?? 1); var viewModel = new ViewDirectorsViewModel() { Directors = directors.ToPagedList(pageNumber, pageSize) }; return(View(viewModel)); }