예제 #1
0
        public async Task AddNotificationAsync(string userId, int theMovieDbId)
        {
            var movie = await _movieSearcher.SearchMovieAsync(new MovieRequest(null, int.MinValue), theMovieDbId);

            _notificationsRepository.AddNotification(userId, int.Parse(movie.TheMovieDbId));
            await _userInterface.DisplayNotificationSuccessAsync(movie);
        }
예제 #2
0
        public async Task NotifyForExistingRequestAsync(string userId, Movie movie)
        {
            if (IsAlreadyNotified(userId, movie))
            {
                await _userInterface.WarnMovieUnavailableAndAlreadyHasNotificationAsync();
            }
            else
            {
                var isRequested = await _userInterface.AskForNotificationRequestAsync();

                if (isRequested)
                {
                    _notificationsRepository.AddNotification(userId, int.Parse(movie.TheMovieDbId));
                    await _userInterface.DisplayNotificationSuccessAsync(movie);
                }
            }
        }
        private async Task HandleMovieSelectionAsync(Movie movie)
        {
            await _userInterface.DisplayMovieDetails(movie);

            if (CanBeRequested(movie))
            {
                var isRequested = await _userInterface.GetMovieRequestAsync();

                if (isRequested)
                {
                    await _requester.RequestMovieAsync(_user.Username, movie);

                    await _userInterface.DisplayRequestSuccess(movie);

                    _notificationRequestRepository.AddNotification(_user.UserId, int.Parse(movie.TheMovieDbId));
                }
            }
            else
            {
                if (movie.Available)
                {
                    await _userInterface.WarnMovieAlreadyAvailable();
                }
                else if (IsAlreadyNotified(movie))
                {
                    await _userInterface.WarnMovieUnavailableAndAlreadyHasNotification();
                }
                else
                {
                    var isRequested = await _userInterface.AskForNotificationRequestAsync();

                    if (isRequested)
                    {
                        _notificationRequestRepository.AddNotification(_user.UserId, int.Parse(movie.TheMovieDbId));
                        await _userInterface.DisplayNotificationSuccessAsync(movie);
                    }
                }
            }
        }