public void Renew( SubscriptionRenewalPaymentSnapshot subscriptionRenewalPayment) { var expirationDate = SubscriptionDateExpirationCalculator.CalculateForRenewal( _expirationDate, subscriptionRenewalPayment.SubscriptionPeriod); SubscriptionRenewedDomainEvent subscriptionRenewedDomainEvent = new SubscriptionRenewedDomainEvent( this.Id, expirationDate, subscriptionRenewalPayment.PayerId.Value, subscriptionRenewalPayment.SubscriptionPeriod.Code, SubscriptionStatus.Active.Code); this.Apply(subscriptionRenewedDomainEvent); this.AddDomainEvent(subscriptionRenewedDomainEvent); }
public static Subscription Create( SubscriptionPaymentSnapshot subscriptionPayment) { var subscription = new Subscription(); var expirationDate = SubscriptionDateExpirationCalculator.CalculateForNew(subscriptionPayment.SubscriptionPeriod); var subscriptionCreatedDomainEvent = new SubscriptionCreatedDomainEvent( subscriptionPayment.Id.Value, Guid.NewGuid(), subscriptionPayment.PayerId.Value, subscriptionPayment.SubscriptionPeriod.Code, subscriptionPayment.CountryCode, expirationDate, SubscriptionStatus.Active.Code); subscription.Apply(subscriptionCreatedDomainEvent); subscription.AddDomainEvent(subscriptionCreatedDomainEvent); return(subscription); }