public ExpirationDate GetExpirationDate() { ExpirationDate result = LicensingModel switch { LicensingModel.TwoDays => ExpirationDate.Create(DateTime.UtcNow.AddDays(2)).Value, LicensingModel.LifeLong => ExpirationDate.Infinite, _ => 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; }
private CustomerStatus(CustomerStatusType type, ExpirationDate expirationDate) : this() { Type = type; ExpirationDate = expirationDate; }