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);
 }
 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;
 }
示例#3
0
        public MoneyValue GetPrice(
            string countryCode,
            SubscriptionPeriod subscriptionPeriod,
            PriceListItemCategory category)
        {
            CheckRule(new PriceForSubscriptionMustBeDefinedRule(countryCode, subscriptionPeriod, _items, category));

            return(_pricingStrategy.GetPrice(countryCode, subscriptionPeriod, category));
        }
        public void ChangeAttributes(
            string countryCode,
            SubscriptionPeriod subscriptionPeriod,
            PriceListItemCategory category,
            MoneyValue price)
        {
            var priceListItemChangedDomainEvent = new PriceListItemAttributesChangedDomainEvent(this.Id, countryCode, subscriptionPeriod.Code, category.Code, price.Value, price.Currency);

            this.Apply(priceListItemChangedDomainEvent);
            this.AddDomainEvent(priceListItemChangedDomainEvent);
        }
 public PriceListItemData(
     string countryCode,
     SubscriptionPeriod subscriptionPeriod,
     MoneyValue value,
     PriceListItemCategory category)
 {
     CountryCode        = countryCode;
     Value              = value;
     Category           = category;
     SubscriptionPeriod = subscriptionPeriod;
 }
        public MoneyValue GetPrice(
            string countryCode,
            SubscriptionPeriod subscriptionPeriod,
            PriceListItemCategory category)
        {
            CheckRule(new PriceForSubscriptionMustBeDefined(countryCode, subscriptionPeriod, _items, category));

            var priceListItem = _items.Single(x =>
                                              x.CountryCode == countryCode && x.SubscriptionPeriod == subscriptionPeriod &&
                                              x.Category == category);

            return(priceListItem.Value);
        }
        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);
        }