private void When(PriceListItemAttributesChangedDomainEvent @event) { this._countryCode = @event.CountryCode; this._subscriptionPeriod = SubscriptionPeriod.Of(@event.SubscriptionPeriodCode); this._category = PriceListItemCategory.Of(@event.CategoryCode); this._price = MoneyValue.Of(@event.Price, @event.Currency); }
public async Task <Guid> Handle(BuySubscriptionRenewalCommand command, CancellationToken cancellationToken) { var priceList = await PriceListProvider.GetPriceList(_sqlConnectionFactory.GetOpenConnection()); var subscriptionId = new SubscriptionId(command.SubscriptionId); var subscription = await _aggregateStore.Load(new SubscriptionId(command.SubscriptionId)); if (subscription == null) { throw new InvalidCommandException(new List <string> { "Subscription for renewal must exist." }); } var subscriptionRenewalPayment = SubscriptionRenewalPayment.Buy( _payerContext.PayerId, subscriptionId, SubscriptionPeriod.Of(command.SubscriptionTypeCode), command.CountryCode, MoneyValue.Of(command.Value, command.Currency), priceList); _aggregateStore.AppendChanges(subscriptionRenewalPayment); return(subscriptionRenewalPayment.Id); }
private void When(SubscriptionPaymentCreatedDomainEvent @event) { this.Id = @event.SubscriptionPaymentId; _payerId = new PayerId(@event.PayerId); _subscriptionPeriod = SubscriptionPeriod.Of(@event.SubscriptionPeriodCode); _countryCode = @event.CountryCode; _subscriptionPaymentStatus = SubscriptionPaymentStatus.Of(@event.Status); _value = MoneyValue.Of(@event.Value, @event.Currency); }
private void When(PriceListItemCreatedDomainEvent @event) { this.Id = @event.PriceListItemId; _countryCode = @event.CountryCode; _subscriptionPeriod = SubscriptionPeriod.Of(@event.SubscriptionPeriodCode); _category = PriceListItemCategory.Of(@event.CategoryCode); _price = MoneyValue.Of(@event.Price, @event.Currency); _isActive = true; }
public Task <Guid> Handle(CreatePriceListItemCommand command, CancellationToken cancellationToken) { var priceListItem = PriceListItem.Create( command.CountryCode, SubscriptionPeriod.Of(command.SubscriptionPeriodCode), PriceListItemCategory.Of(command.CategoryCode), MoneyValue.Of(command.PriceValue, command.PriceCurrency)); _aggregateStore.AppendChanges(priceListItem); return(Task.FromResult(priceListItem.Id)); }
public async Task <Unit> Handle(ChangePriceListItemAttributesCommand command, CancellationToken cancellationToken) { var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId)); priceListItem.ChangeAttributes( command.CountryCode, SubscriptionPeriod.Of(command.SubscriptionPeriodCode), PriceListItemCategory.Of(command.CategoryCode), MoneyValue.Of(command.PriceValue, command.PriceCurrency)); _aggregateStore.AppendChanges(priceListItem); return(Unit.Value); }
public static async Task <PriceList> GetPriceList(IDbConnection connection) { var priceListItemList = await GetPriceListItems(connection); return(PriceList.CreateFromItems( priceListItemList .Select(x => new PriceListItemData( x.CountryCode, SubscriptionPeriod.Of(x.SubscriptionPeriodCode), MoneyValue.Of(x.MoneyValue, x.MoneyCurrency), PriceListItemCategory.Of(x.CategoryCode))) .ToList())); }
public async Task <Guid> Handle(BuySubscriptionCommand command, CancellationToken cancellationToken) { var priceList = await PriceListProvider.GetPriceList(_sqlConnectionFactory.GetOpenConnection()); var subscription = SubscriptionPayment.Buy( _payerContext.PayerId, SubscriptionPeriod.Of(command.SubscriptionTypeCode), command.CountryCode, MoneyValue.Of(command.Value, command.Currency), priceList); _aggregateStore.AppendChanges(subscription); return(subscription.Id); }
public async Task <Unit> Handle(ChangePriceListItemAttributesCommand command, CancellationToken cancellationToken) { var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId)); if (priceListItem == null) { throw new InvalidCommandException(new List <string> { "Pricelist item for changing must exist." }); } priceListItem.ChangeAttributes( command.CountryCode, SubscriptionPeriod.Of(command.SubscriptionPeriodCode), PriceListItemCategory.Of(command.CategoryCode), MoneyValue.Of(command.PriceValue, command.PriceCurrency)); _aggregateStore.AppendChanges(priceListItem); return(Unit.Value); }
public static async Task <PriceList> CreatePriceList(IDbConnection connection) { var priceListItemList = await GetPriceListItems(connection); var priceListItems = priceListItemList .Select(x => new PriceListItemData( x.CountryCode, SubscriptionPeriod.Of(x.SubscriptionPeriodCode), MoneyValue.Of(x.MoneyValue, x.MoneyCurrency), PriceListItemCategory.Of(x.CategoryCode))) .ToList(); // This is place for selecting pricing strategy based on provided data and the system state. IPricingStrategy pricingStrategy = new DirectValueFromPriceListPricingStrategy(priceListItems); return(PriceList.Create( priceListItems, pricingStrategy)); }