Exemplo n.º 1
0
        public async Task <PaginatedData <StickerPackOutput> > FindAllStickerPacksAsync(
            StickerPackSorting sorting,
            StickerPackNameFilter nameFilter,
            StickerPackClapsFilter clapsFilter,
            StickerPackTagsFilter tagsFilter,
            Pagination pagination
            )
        {
            var stickerPacks = _stickerPackRepository.FindAll();

            stickerPacks = ApplySorting(stickerPacks, sorting.SortBy, sorting.SortType);
            stickerPacks = ApplyNameFilter(stickerPacks, nameFilter);
            stickerPacks = ApplyClapsFilter(stickerPacks, clapsFilter);
            stickerPacks = await ApplyTagsFilterAsync(stickerPacks, tagsFilter);

            var paginatedStickers = await stickerPacks.PaginateAsync(pagination);

            var result = new PaginatedData <StickerPackOutput>(paginatedStickers.Total, new List <StickerPackOutput>());

            foreach (var stickerPack in paginatedStickers.Data)
            {
                var stickers = await _tgBot.GetStickerFilesFromPackAsync(stickerPack.Name);

                var filePath = await _tgBot.GetFilePathAsync(stickerPack.Name, fileId : stickers.First());

                result.Data = result.Data.Append(new StickerPackOutput(stickerPack, filePath, stickers.Count()));
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task <StickerPackOutput> GetStickerPackByIdAsync([FromRoute] Guid stickerPackId)
        {
            var stickerPack = await _stickerPackService.GetStickerPackAsync(stickerPackId);

            var stickers = await _tgBot.GetStickerFilesFromPackAsync(stickerPack.Name);

            var filePath = await _tgBot.GetFilePathAsync(stickerPack.Name, fileId : stickers.First());

            return(new StickerPackOutput(stickerPack, firstStickerPath: filePath, stickersCount: stickers.Count()));
        }