Example #1
0
        private async Task <TvSeasonsSelection> GetTvShowSelectionBasedOnRestrictions(TvShow tvShow)
        {
            TvSeasonsSelection seasonSelection = null;

            if (_settings.Restrictions == TvShowsRestrictions.AllSeasons)
            {
                seasonSelection = new TvSeasonsSelection
                {
                    SelectedSeason = tvShow.Seasons.OfType <AllTvSeasons>().Single()
                };
            }
            else if (_settings.Restrictions == TvShowsRestrictions.SingleSeason)
            {
                tvShow.Seasons  = tvShow.Seasons.Where(x => !(x is AllTvSeasons)).ToArray();
                seasonSelection = await _userInterface.GetTvShowSeasonSelectionAsync(tvShow);
            }
            else if (_settings.Restrictions == TvShowsRestrictions.None)
            {
                seasonSelection = await _userInterface.GetTvShowSeasonSelectionAsync(tvShow);
            }
            else
            {
                throw new NotImplementedException($"Tv shows restriction of type {_settings.Restrictions} has not been implemented.");
            }

            return(seasonSelection);
        }
Example #2
0
        private async Task RequestTvShowSeason(TvShow tvShow)
        {
            var seasonSelection = await _userInterface.GetTvShowSeasonSelectionAsync(tvShow);

            if (!seasonSelection.IsCancelled && seasonSelection.SelectedSeason.IsSpecified)
            {
                var selectedSeason = seasonSelection.SelectedSeason.Value;

                switch (selectedSeason)
                {
                case FutureTvSeasons futureTvSeasons:
                    await new FutureSeasonsRequestingWorkflow(_user, _searcher, _requester, _userInterface, _notificationRequestRepository)
                    .HandleRequestAsync(tvShow, futureTvSeasons);
                    break;

                case AllTvSeasons allTvSeasons:
                    await new AllSeasonsRequestingWorkflow(_user, _searcher, _requester, _userInterface, _notificationRequestRepository)
                    .HandleRequestAsync(tvShow, allTvSeasons);
                    break;

                case NormalTvSeason normalTvSeason:
                    await new NormalTvSeasonRequestingWorkflow(_user, _searcher, _requester, _userInterface, _notificationRequestRepository)
                    .HandleRequestAsync(tvShow, normalTvSeason);
                    break;

                default:
                    throw new Exception($"Could not handle season of type \"{selectedSeason.GetType().Name}\"");
                }
            }
            else if (!seasonSelection.IsCancelled)
            {
                await _userInterface.WarnInvalidSeasonSelectionAsync();
            }
        }