コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }