コード例 #1
0
 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;
 }
コード例 #2
0
 private async Task When(PriceListItemCreatedDomainEvent @event)
 {
     await _connection.ExecuteScalarAsync(
         "INSERT INTO payments.PriceListItems " +
         "([Id], [SubscriptionPeriodCode], [CategoryCode], [CountryCode], [MoneyValue], [MoneyCurrency], [IsActive])" +
         "VALUES (@PriceListItemId, @SubscriptionPeriodCode, @CategoryCode, @CountryCode, @Price, @Currency, @IsActive)",
         new
     {
         @event.PriceListItemId,
         @event.SubscriptionPeriodCode,
         @event.CategoryCode,
         @event.CountryCode,
         @event.Price,
         @event.Currency,
         @event.IsActive
     });
 }
コード例 #3
0
        public static PriceListItem Create(
            string countryCode,
            SubscriptionPeriod subscriptionPeriod,
            PriceListItemCategory category,
            MoneyValue price)
        {
            var priceListItem = new PriceListItem();

            var priceListItemCreatedEvent = new PriceListItemCreatedDomainEvent(
                Guid.NewGuid(),
                countryCode,
                subscriptionPeriod.Code,
                category.Code,
                price.Value,
                price.Currency,
                isActive: true);

            priceListItem.Apply(priceListItemCreatedEvent);
            priceListItem.AddDomainEvent(priceListItemCreatedEvent);

            return(priceListItem);
        }