public async Task <PagedBookingsList <BookingSectorDTO> > GetTournamentBookingsPagedList(BookingTableParams bookingParams) { DateTime date = DateTime.Now.AddDays(-1); var bookings = await database.BookingSectorRepository.GetAllEntitiesAsync(); var tournamentBookings = bookings.Where(b => b.TournamentId.HasValue).OrderBy(b => b.TournamentId & b.SectorId); IEnumerable <BookingSector> pagedBookings = new List <BookingSector>(); if (!bookingParams.isExpired) { pagedBookings = from booking in tournamentBookings where booking.IsApproved == bookingParams.isApproved select booking; } else if (bookingParams.isExpired) { pagedBookings = from booking in tournamentBookings where booking.BookingStart < date select booking; } var dtos = mapper.Map <IEnumerable <BookingSector>, IEnumerable <BookingSectorDTO> >(pagedBookings); return(PagedBookingsList <BookingSectorDTO> .toPagedList(dtos, bookingParams.pageIndex, bookingParams.pageSize)); }
public async Task <PagedBookingsList <BookingSectorDTO> > GetBookingsPagedList(BookingTableParams bookingParams) { DateTime date = DateTime.Now.AddDays(-1); var bookings = await database.BookingSectorRepository.GetAllEntitiesAsync(); IEnumerable <BookingSector> conditionalBookings = new List <BookingSector>(); if (!bookingParams.isExpired) { conditionalBookings = from booking in bookings where booking.IsApproved == bookingParams.isApproved where booking.TournamentId == null select booking; } else if (bookingParams.isExpired) { conditionalBookings = from booking in bookings where booking.BookingStart < date where booking.TournamentId == null select booking; } var dtos = mapper.Map <IEnumerable <BookingSector>, IEnumerable <BookingSectorDTO> >(conditionalBookings); return(PagedBookingsList <BookingSectorDTO> .toPagedList(dtos, bookingParams.pageIndex, bookingParams.pageSize));; }