public Customer(CustomerName name, Email email) { Name = name; Email = email; MoneySpent = Dollars.Of(0); Status = CustomerStatus.Regular; }
private Dollars GetBasePrice() { Dollars result = LicensingModel switch { LicensingModel.TwoDays => Dollars.Of(4), LicensingModel.LifeLong => Dollars.Of(8), _ => throw new ArgumentOutOfRangeException() }; return(result); } }
public void PurchaseMovie(Movie movie, DateTime now) { if (HasPurchasedMovie(movie, now)) { throw new Exception(); } ExpirationDate expirationDate = movie.GetExpirationDate(); Dollars price = movie.CalculatePrice(Status, DateTime.UtcNow); var purchasedMovie = new PurchasedMovie(movie.Id, Id, price, now, expirationDate); _purchasedMovies.Add(purchasedMovie); MoneySpent += price; }
public PurchasedMovie(long movieId, long customerId, Dollars price, DateTime now, ExpirationDate expirationDate) { if (price == null || price.IsZero) { throw new ArgumentException(nameof(price)); } if (expirationDate == null || expirationDate.IsExpired(now)) { throw new ArgumentException(nameof(expirationDate)); } MovieId = movieId; CustomerId = customerId; Price = price; PurchaseDate = now; ExpirationDate = expirationDate; }