public async Task <PaginationDto <BookGetDto> > GetAllAsync(BookQueryParams parameters) { if (parameters.LocationFilterOn == true && (parameters.HomeLocations == null || parameters.HomeLocations.Length == 0) && (parameters.Locations == null || parameters.Locations.Length == 0)) { return(new PaginationDto <BookGetDto>() { TotalCount = 0, Page = new List <BookGetDto>() }); } var query = GetFilteredQuery(_bookRepository.GetAll(), parameters); if (parameters.HomeLocations?.Length > 0) { var queryBooksAtHome = GetFilteredQuery(_bookRepository.GetAll(), parameters, false); query = query.Union(queryBooksAtHome); } if (parameters.SortableParams != null) { query = query.OrderBy(parameters.SortableParams); } return(await _paginationService.GetPageAsync <BookGetDto, Book>(query, parameters)); }
public async Task <PaginationDto <UserDto> > GetAllUsers(FullPaginationQueryParams parameters) { var userList = _userRepository.GetAll().Include(p => p.UserRoom); var paginatedListOfUsers = await _paginationService.GetPageAsync <UserDto, User>(userList, parameters); paginatedListOfUsers.Page.ForEach(async user => user.NumberOfBooksOwned = await _bookService.GetCurrentOwnedByIdCount(user.Id)); return(paginatedListOfUsers); }
public async Task <ActionResult <PaginationDto <PlayerDto> > > GetAllPlayers([FromQuery] FullPaginationQueryParams fullPaginationQuery) { var players = _unitOfWork.GetRepository().GetAll() .Include(p => p.Contract) .Include(p => p.PlayerMatches); return(await _paginationService.GetPageAsync <PlayerDto, Player>(players, fullPaginationQuery)); }
public async Task <ActionResult <PaginationDto <MatchBroadcastDto> > > GetAllBroadcasts( [FromQuery] FullPaginationQueryParams fullPaginationQuery) { var broadcasts = _unitOfWork.GetRepository() .GetAll() .Include(x => x.MatchTournament); return(await _paginationService.GetPageAsync <MatchBroadcastDto, MatchBroadcast>(broadcasts, fullPaginationQuery)); }
public async Task <PaginationDto <PostGetDto> > GetAllAsync(PostQueryParams queryParams) { var posts = _postRepository.GetAll(); posts = posts.Include(p => p.User).Include(p => p.Tags).ThenInclude(p => p.Tag); if (queryParams.SortableParams != null) { posts = posts.OrderBy(queryParams.SortableParams); } posts = GetFilteredQuery(posts, queryParams); var page = await _paginationService.GetPageAsync <PostGetDto, Post>(posts, queryParams); return(page); }
public async Task <PaginationDto <BookGetDto> > GetWishesOfCurrentUserAsync(PageableParams pageableParams) { var currentUserId = _userResolverService.GetUserId(); var wishesQuery = _wishRepository.GetAll() .Include(wish => wish.Book.Language) .Include(wish => wish.Book.BookAuthor).ThenInclude(bookAuthor => bookAuthor.Author) .Include(wish => wish.Book.BookGenre).ThenInclude(bookGenre => bookGenre.Genre) .Include(wish => wish.Book.User.UserRoom.Location) .Where(wish => wish.UserId == currentUserId) .Select(wish => wish.Book); var wishesPaginated = await _paginationService.GetPageAsync <BookGetDto, Book>(wishesQuery, pageableParams); return(wishesPaginated); }
public async Task <ActionResult <PaginationDto <Payment> > > GetAllMatches([FromQuery] FullPaginationQueryParams fullPaginationQuery) { var payments = _unitOfWork.GetRepository().GetAll(); return(await _paginationService.GetPageAsync <Payment, Payment>(payments, fullPaginationQuery)); }
public async Task <PaginationDto <IssueDto> > GetAll(FullPaginationQueryParams fullPaginationQuery) { var query = _issueRepository.GetAll(); return(await _paginationService.GetPageAsync <IssueDto, Issue>(query, fullPaginationQuery)); }
public async Task <ActionResult <PaginationDto <TrainingDto> > > GetAllTraining([FromQuery] FullPaginationQueryParams fullPaginationQuery) { var trainings = _unitOfWork.GetRepository().GetAll(); return(await _paginationService.GetPageAsync <TrainingDto, Training>(trainings, fullPaginationQuery)); }
public async Task <PaginationDto <SuggestionMessageDto> > GetAll(FullPaginationQueryParams fullPaginationQuery) { var query = _messageRepository.GetAll().AsNoTracking().Include(u => u.User).ThenInclude(r => r.Role).IgnoreQueryFilters(); return(await _paginationService.GetPageAsync <SuggestionMessageDto, SuggestionMessage>(query, fullPaginationQuery)); }
public async Task <PaginationDto <LocationDto> > GetAll(FullPaginationQueryParams parameters) { var query = _locationRepository.GetAll().IgnoreQueryFilters(); return(await _paginationService.GetPageAsync <LocationDto, Location>(query, parameters)); }
public async Task <PaginationDto <AuthorDto> > GetAll(FullPaginationQueryParams parameters) { var query = _authorRepository.GetAll(); return(await _paginationService.GetPageAsync <AuthorDto, Author>(query, parameters)); }
/// <inheritdoc /> public async Task <PaginationDto <RequestDto> > GetAsync(Expression <Func <Request, bool> > predicate, BookQueryParams parameters) { var books = _bookRepository.GetAll(); var author = _bookAuthorRepository.GetAll(); if (parameters.SearchTerm != null) { var term = parameters.SearchTerm.Split(" "); if (term.Length <= 1) { author = author.Where(a => a.Author.FirstName.Contains(term[0]) || a.Author.LastName.Contains(term[0]) || a.Book.Name.Contains(parameters.SearchTerm)); } else { author = author.Where(a => a.Author.FirstName.Contains(term[0]) && a.Author.LastName.Contains(term[term.Length - 1]) || a.Book.Name.Contains(parameters.SearchTerm)); } } var genre = _bookGenreRepository.GetAll(); if (parameters.Genres != null) { var wherePredicate = PredicateBuilder.New <BookGenre>(); foreach (var id in parameters.Genres) { var tempId = id; wherePredicate = wherePredicate.Or(g => g.Genre.Id == tempId); } genre = genre.Where(wherePredicate); } var lang = _bookLanguageRepository.GetAll(); if (parameters.Languages != null) { var wherePredicate = PredicateBuilder.New <Language>(); foreach (var id in parameters.Languages) { var tempId = id; wherePredicate = wherePredicate.Or(g => g.Id == tempId); } lang = lang.Where(wherePredicate); } if (parameters.ShowAvailable == true) { books = books.Where(b => b.State == BookState.Available); } var location = _userLocationRepository.GetAll(); if (parameters.Locations != null) { var wherePredicate = PredicateBuilder.New <UserRoom>(); foreach (var id in parameters.Locations) { var tempId = id; wherePredicate = wherePredicate.Or(r => r.LocationId == tempId); } location = location.Where(wherePredicate); } var bookIds = from b in books join g in genre on b.Id equals g.BookId join la in lang on b.Language.Id equals la.Id join a in author on b.Id equals a.BookId join l in location on b.User.UserRoomId equals l.Id select b.Id; var query = _requestRepository.GetAll() .Include(i => i.Book).ThenInclude(i => i.BookAuthor).ThenInclude(i => i.Author) .Include(i => i.Book).ThenInclude(i => i.BookGenre).ThenInclude(i => i.Genre) .Include(i => i.Book).ThenInclude(i => i.Language) .Include(i => i.Owner).ThenInclude(i => i.UserRoom).ThenInclude(i => i.Location) .Include(i => i.User).ThenInclude(i => i.UserRoom).ThenInclude(i => i.Location) .Where(predicate).Where(x => bookIds.Contains(x.BookId)); return(await _paginationService.GetPageAsync <RequestDto, Request>(query, parameters)); }
public async Task <ActionResult <PaginationDto <Income> > > GetAllMatches([FromQuery] FullPaginationQueryParams fullPaginationQuery) { var incomes = _unitOfWork.GetRepository().GetAll(); return(await _paginationService.GetPageAsync <Income, Income>(incomes, fullPaginationQuery)); }
public async Task <PaginationDto <LanguageDto> > GetAll(FullPaginationQueryParams parameters) { var query = _languageRepository.GetAll(); return(await _paginationService.GetPageAsync <LanguageDto, Language>(query, parameters)); }