public PurchaseResponse PurchaseMovie(Customer customer, Movie movie) { if (customer.MoviePurchases.Select(r => r.MovieId).Contains(movie.Id)) { throw new MovieAlreadyPurchasedException("Movie already purchased."); } if (!paymentService.Pay(customer, movie)) { InvalidateCustomerCreditCard(customer); throw new PaymentFailedException( $"Payment failed for customer {customer.FullName.ToString()}. " + "Please check and update your credit card details." ); } var moviePurchase = MoviePurchase.Create(customer, movie); customersRepository.AddMoviePurchase(moviePurchase); FinishCurrentRentalIfExists(customer, movie); var movieLinkWithDownload = streamingService.GetMovieStreamWithDownload(movie); return(new PurchaseResponse(moviePurchase, movieLinkWithDownload)); }