コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecordPurchase"/> class.
        /// </summary>
        /// <param name="repository">A customer purchases repository which manages customer purchases persistence.</param>
        /// <param name="newPurchaseRecord">The new customer purchase to record.</param>
        public RecordPurchase(CustomerPurchasesRepository repository, CustomerPurchaseEntity newPurchaseRecord)
        {
            repository.AssertNotNull(nameof(repository));
            newPurchaseRecord.AssertNotNull(nameof(newPurchaseRecord));

            this.CustomerPurchasesRepository = repository;
            this.CustomerPurchaseToPersist   = newPurchaseRecord;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PersistNewlyPurchasedSubscriptions"/> class.
        /// </summary>
        /// <param name="customerId">The ID of the customer who performed the purchases.</param>
        /// <param name="subscriptionsRepository">The customer subscriptions repository used to persist the subscriptions.</param>
        /// <param name="purchasesRepository">The customer purchases repository used to persist the purchases.</param>
        /// <param name="acquireInputsFunction">The function used to obtain the order and the list of purchase line items associated with their partner offers.</param>
        public PersistNewlyPurchasedSubscriptions(
            string customerId,
            CustomerSubscriptionsRepository subscriptionsRepository,
            CustomerPurchasesRepository purchasesRepository,
            Func <Tuple <Order, IEnumerable <PurchaseLineItemWithOffer> > > acquireInputsFunction)
        {
            customerId.AssertNotEmpty(nameof(customerId));
            subscriptionsRepository.AssertNotNull(nameof(subscriptionsRepository));
            purchasesRepository.AssertNotNull(nameof(purchasesRepository));
            acquireInputsFunction.AssertNotNull(nameof(acquireInputsFunction));

            this.CustomerId = customerId;
            this.CustomerSubscriptionsRepository = subscriptionsRepository;
            this.CustomerPurchasesRepository     = purchasesRepository;
            this.AcquireInput = acquireInputsFunction;
        }