Exemplo n.º 1
0
        public Task NotifyForNewRequestAsync(string userId, Movie movie)
        {
            if (_automaticNotificationForNewRequests)
            {
                _notificationsRepository.AddNotification(userId, int.Parse(movie.TheMovieDbId));
            }

            return(Task.CompletedTask);
        }
        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);
                    }
                }
            }
        }