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; }
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 }); }
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); }