예제 #1
0
        public async Task <TvSeasonDetailModel> Handle(GetTvSeasonDetailsQuery request, CancellationToken cancellationToken)
        {
            var tvSeasonDetails = await _theMovieDbService.GetTvSeasonDetails(request.TvId, request.SeasonNumber);

            var tvSeasonDetailModel = await _tvQueryHelper.CreateSeasonDetailModel(request.TvId, tvSeasonDetails);

            return(tvSeasonDetailModel);
        }
        private async Task AddNewRootLevelRequests(TvRequestRow existingRequest, List <TvRequestSeasonRow> seasonsToRequest)
        {
            foreach (var seasonToRequest in seasonsToRequest)
            {
                var seasonDetails = await _theMovieDbService.GetTvSeasonDetails(existingRequest.TheMovieDbId, seasonToRequest.SeasonIndex);

                var rootSeason = existingRequest.TvRequestSeasons.FirstOrDefault(x => x.SeasonIndex == seasonToRequest.SeasonIndex);
                if (seasonDetails != null && rootSeason == null)
                {
                    rootSeason = new TvRequestSeasonRow
                    {
                        AirDateUtc    = DateTime.Parse(seasonDetails.Air_Date),
                        Title         = seasonDetails.Name,
                        ImagePath     = seasonDetails.Poster_Path,
                        RequestStatus = RequestStatuses.PendingApproval
                    };
                }

                SetEpisodeDetails(rootSeason, seasonToRequest.TvRequestEpisodes, seasonDetails);

                existingRequest.TvRequestSeasons.Add(rootSeason);
            }
        }