public async Task <PagedResultDTO <BandDTO> > GetBandsPageAsync(int page, int pageSize, BandFilterDTO bandFilterDTO) { IQueryable <BandEntity> query = _DBContext.Bands .Include(band => band.BandGenres) .ThenInclude(bg => bg.Genre); var predicate = PredicateBuilderHelper.True <BandEntity>(); if (bandFilterDTO.FestivalId != null) { predicate = predicate.And(band => band.Performances.Any(p => p.FestivalId == bandFilterDTO.FestivalId)); } if (bandFilterDTO.StageId != null) { predicate = predicate.And(band => band.Performances.Any(p => p.StageId == bandFilterDTO.StageId)); } if (bandFilterDTO.GenreIds != null) { //TO DO //Потрібно щоб група одночасно належала до всіх вибраних жанрів. //Чи не треба? predicate = predicate.And(band => band.BandGenres.Any(bg => bandFilterDTO.GenreIds.Contains(bg.GenreId))); } query = query.Where(predicate); var pagedResult = await _DBContext.GetPage <BandEntity, BandDTO>(_mapper, query, page, pageSize); return(pagedResult); }
public async Task <PagedResultDTO <AdminDTO> > GetAdminsPageAsync(int page, int pageSize) { var query = _DBContext.Admins; var pagedResult = await _DBContext.GetPage <AdminEntity, AdminDTO>(_mapper, query, page, pageSize); return(pagedResult); }
public async Task <PagedResultDTO <CustomerDTO> > GetCustomersPageAsync(int page, int pageSize) { var query = _DBContext.Customers; var pagedResult = await _DBContext.GetPage <CustomerEntity, CustomerDTO>(_mapper, query, page, pageSize); return(pagedResult); }
public async Task <PagedResultDTO <GenreDTO> > GetGenresPageAsync(int page, int pageSize) { var query = _DBContext.Genres.AsNoTracking(); var pagedResult = await _DBContext.GetPage <GenreEntity, GenreDTO>(_mapper, query, page, pageSize); return(pagedResult); }
public async Task <PagedResultDTO <PurchaseDTO> > GetPurchasesPageAsync(int page, int pageSize) { var query = _DBContext.Purchases .Include(p => p.Ticket) .Include(p => p.Customer); var pagedResult = await _DBContext.GetPage <PurchaseEntity, PurchaseDTO>(_mapper, query, page, pageSize); return(pagedResult); }
public async Task <PagedResultDTO <PerformanceDTO> > GetPerformancesPageAsync(int page, int pageSize, PerformanceFilterDTO performanceFilterDTO) { IQueryable <PerformanceEntity> query = _DBContext.Performances .Include(p => p.Band) .ThenInclude(b => b.BandGenres) .ThenInclude(db => db.Genre) .Include(p => p.Stage) .Include(p => p.Festival); var predicate = PredicateBuilderHelper.True <PerformanceEntity>(); predicate = predicate.And(performance => performance.FestivalId == performanceFilterDTO.FestivalId); if (performanceFilterDTO.StageId != null) { predicate = predicate.And(performance => performance.StageId == performanceFilterDTO.StageId); } query = query.Where(predicate); var pagedResult = await _DBContext.GetPage <PerformanceEntity, PerformanceDTO>(_mapper, query, page, pageSize); return(pagedResult); }