public async Task <IActionResult> Index(string sortOrder, int?pageNumber, int pageSize = 5) { try { List <BookingModel> bookingList = await ApiConnection.GetBookingList(); List <CategoryModel> categoryList = await ApiConnection.GetCategoryList(); List <RoomdescModel> roomdescList = await ApiConnection.GetRoomdescList(); BookingHandler.PlaceCategoryInBooking(bookingList, categoryList, roomdescList); //placerar kategoribeskrivning i bokningslistan ViewData["CurrentSort"] = sortOrder; ViewDataImport(sortOrder); bookingList = BookingListViewHelper.ColumnSwitch(sortOrder, bookingList); return(View(await PaginatedList <BookingModel> .CreatePaging(bookingList, pageNumber ?? 1, pageSize))); } catch (Exception ex) { _logger.LogWarning("Could not fetch bookings", ex); return(RedirectToAction("Privacy", "Home")); } }