コード例 #1
0
        public async Task AddNotificationAsync(string userId, int theTvDbId, string seasonType, int seasonNumber)
        {
            TvSeason selectedSeason;

            var tvShow = await _tvShowSearcher.GetTvShowDetailsAsync(new TvShowRequest(null, int.MinValue), theTvDbId);

            switch (seasonType.ToLower())
            {
            case "f":
                selectedSeason = new FutureTvSeasons {
                    SeasonNumber = seasonNumber
                };
                break;

            case "a":
                selectedSeason = new AllTvSeasons {
                    SeasonNumber = seasonNumber
                };
                break;

            case "n":
                selectedSeason = new NormalTvSeason {
                    SeasonNumber = seasonNumber
                };
                break;

            default:
                throw new Exception($"Could not handle season of type \"{seasonType}\" when adding notifications");
            }

            _notificationsRepository.AddSeasonNotification(userId, theTvDbId, selectedSeason);
            await _userInterface.DisplayNotificationSuccessForSeasonAsync(tvShow, selectedSeason);
        }
コード例 #2
0
        public async Task RequestAsync(TvShow tvShow, FutureTvSeasons selectedSeason)
        {
            await _userInterface.DisplayTvShowDetailsAsync(tvShow);

            if (tvShow.IsRequested)
            {
                await _tvShowNotificationWorkflow.NotifyForExistingRequestAsync(_user.UserId, tvShow, selectedSeason);
            }
            else
            {
                var wasRequested = await _userInterface.GetTvShowRequestConfirmationAsync(selectedSeason);

                if (wasRequested)
                {
                    var result = await _requester.RequestTvShowAsync(_user, tvShow, selectedSeason);

                    if (result.WasDenied)
                    {
                        await _userInterface.DisplayRequestDeniedForSeasonAsync(selectedSeason);
                    }
                    else
                    {
                        await _userInterface.DisplayRequestSuccessForSeasonAsync(selectedSeason);

                        await _tvShowNotificationWorkflow.NotifyForNewRequestAsync(_user.UserId, tvShow, selectedSeason);
                    }
                }
            }
        }
コード例 #3
0
 public async Task HandleSelectionAsync(TvShowRequest request, TvShow tvShow, FutureTvSeasons selectedSeason)
 {
     if (tvShow.IsRequested)
     {
         await _tvShowNotificationWorkflow.NotifyForExistingRequestAsync(request.User.UserId, tvShow, selectedSeason);
     }
     else
     {
         await _userInterface.DisplayTvShowDetailsForSeasonAsync(request, tvShow, selectedSeason);
     }
 }
コード例 #4
0
        public async Task RequestAsync(TvShowRequest request, TvShow tvShow, FutureTvSeasons selectedSeason)
        {
            var result = await _requester.RequestTvShowAsync(request, tvShow, selectedSeason);

            if (result.WasDenied)
            {
                await _userInterface.DisplayRequestDeniedForSeasonAsync(tvShow, selectedSeason);
            }
            else
            {
                await _userInterface.DisplayRequestSuccessForSeasonAsync(tvShow, selectedSeason);

                await _tvShowNotificationWorkflow.NotifyForNewRequestAsync(request.User.UserId, tvShow, selectedSeason);
            }
        }
コード例 #5
0
        private async Task RequestNotificationsForSeasonAsync(TvShow tvShow, FutureTvSeasons selectedSeason)
        {
            if (_notificationRequestRepository.HasSeasonNotification(_user.UserId, tvShow.TheTvDbId, selectedSeason))
            {
                await _userInterface.WarnAlreadyNotifiedForSeasonsAsync(tvShow, selectedSeason);
            }
            else
            {
                var isRequested = await _userInterface.AskForSeasonNotificationRequestAsync(tvShow, selectedSeason);

                if (isRequested)
                {
                    _notificationRequestRepository.AddSeasonNotification(_user.UserId, tvShow.TheTvDbId, selectedSeason);
                    await _userInterface.DisplayNotificationSuccessForSeasonAsync(selectedSeason);
                }
            }
        }
コード例 #6
0
        public async Task HandleRequestAsync(TvShow tvShow, FutureTvSeasons selectedSeason)
        {
            await _userInterface.DisplayTvShowDetailsAsync(tvShow);

            if (tvShow.IsRequested)
            {
                await RequestNotificationsForSeasonAsync(tvShow, selectedSeason);
            }
            else
            {
                var wasRequested = await _userInterface.GetTvShowRequestConfirmation(selectedSeason);

                if (wasRequested)
                {
                    await _requester.RequestTvShowAsync(_user.Username, tvShow, selectedSeason);

                    _notificationRequestRepository.AddSeasonNotification(_user.UserId, tvShow.TheTvDbId, selectedSeason);
                    await _userInterface.DisplayRequestSuccessForSeasonAsync(selectedSeason);
                }
            }
        }