// GET: Sports public async Task <IActionResult> Index(int?page) { await auditLogger.log(GetUserId(), "Accessed Sport Index"); var sportsQ = sportRepository.GetAllAsync().OrderBy(s => s.SportName); var sportsList = await sportsQ.ToListAsync(); var pageNumber = page ?? 1; var sportsPerPage = 10; var onePageOfSports = sportsList.ToPagedList(pageNumber, sportsPerPage); ViewBag.onePageOfSports = onePageOfSports; return(View()); }
// GET: Venues public async Task <IActionResult> Index(int?page) { await auditLogger.log(GetUserId(), "Accessed Venue Index"); IQueryable <Venue> venues = venueRepository.GetAllAsync().OrderBy(v => v.VenueName); venues = venues.OrderBy(v => v.VenueName); var venueList = await venues.ToListAsync(); var pageNumber = page ?? 1; // if no page was specified in the querystring, default to the first page (1) var venuesPerPage = 10; var onePageOfVenue = venueList.ToPagedList(pageNumber, venuesPerPage); // will only contain 25 products max because of the pageSize ViewBag.onePageOfVenue = onePageOfVenue; return(View()); }
// GET: Facilities public async Task <IActionResult> Index(int?page, string sortOrder) { await auditLogger.log(GetUserId(), "Accessed Index Facilities"); ViewData["VenueSortParm"] = sortOrder == "Venue" ? "venue_desc" : "Venue"; ViewData["SportSortParm"] = sortOrder == "Sport" ? "sport_desc" : "Sport"; IQueryable <Facility> facilities = facilityRepository.GetAllAsync().Include(f => f.Sport).Include(f => f.Venue); switch (sortOrder) { case "venue_desc": facilities = facilities.OrderByDescending(f => f.Venue.VenueName); break; case "Sport": facilities = facilities.OrderBy(f => f.Sport.SportName); break; case "sport_desc": facilities = facilities.OrderByDescending(f => f.Sport.SportName); break; default: facilities = facilities.OrderBy(f => f.Venue.VenueName); break; } var facilitiesList = await facilities.ToListAsync(); var pageNumber = page ?? 1; // if no page was specified in the querystring, default to the first page (1) var facilitiesPerPage = 10; var onePageOfFacilities = facilitiesList.ToPagedList(pageNumber, facilitiesPerPage); // will only contain 25 products max because of the pageSize ViewBag.onePageOfFacilities = onePageOfFacilities; return(View()); }
// GET: Bookings public async Task <IActionResult> Index(int?page, string sortOrder) { await auditLogger.log(GetUserId(), "Accessed Booking Index"); ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; ViewData["VenueSortParm"] = sortOrder == "Venue" ? "venue_desc" : "Venue"; ViewData["UserSortParm"] = sortOrder == "User" ? "user_desc" : "User"; IQueryable <Booking> booking_facilitiesContext = bookingRepository.GetAllAsync().Include(b => b.Facility) .Include(b => b.Facility.Venue) .Include(b => b.Facility.Sport) .Where(b => (DateTime.Compare(b.EndBookingDateTime, DateTime.Now) >= 0)); if (!User.Claims.FirstOrDefault(c => c.Type == "user_type").Value.Equals("administrator")) { booking_facilitiesContext = booking_facilitiesContext.Where(b => b.UserId.Equals(GetUserId()) || b.IsBlock); } switch (sortOrder) { case "date_desc": booking_facilitiesContext = booking_facilitiesContext.OrderByDescending(b => b.BookingDateTime); break; case "Venue": booking_facilitiesContext = booking_facilitiesContext.OrderBy(b => b.Facility.Venue); break; case "venue_desc": booking_facilitiesContext = booking_facilitiesContext.OrderByDescending(b => b.Facility.Venue); break; case "User": booking_facilitiesContext = booking_facilitiesContext.OrderBy(b => b.UserId); break; case "user_desc": booking_facilitiesContext = booking_facilitiesContext.OrderByDescending(b => b.UserId); break; default: booking_facilitiesContext = booking_facilitiesContext.OrderBy(b => b.BookingDateTime); break; } var bookingList = await booking_facilitiesContext.ToListAsync(); List <string> userList = new List <string>(); foreach (Booking b in bookingList) { userList.Add(b.UserId); } var response = await apiClient.PostAsync(AppConfig.GetValue <string>("GatekeeperUrl") + "api/Users/Batch", userList.Distinct()); JArray jsonArrayOfUsers = JArray.Parse(await response.Content.ReadAsStringAsync()); foreach (Booking b in bookingList) { foreach (JObject j in jsonArrayOfUsers) { if (b.UserId == j.GetValue("id").ToString()) { b.UserId = j.GetValue("email").ToString(); } else { b.UserId = "Unknown User"; } } } var pageNumber = page ?? 1; // if no page was specified in the querystring, default to the first page (1) var bookingsPerPage = 10; var onePageOfBookings = bookingList.ToPagedList(pageNumber, bookingsPerPage); // will only contain 25 products max because of the pageSize ViewBag.onePageOfBookings = onePageOfBookings; return(View()); }