/// <summary>
        /// Adds the variable value product.
        /// </summary>
        /// <param name="productId">The product identifier.</param>
        /// <param name="productName">Name of the product.</param>
        /// <param name="displayText">The display text.</param>
        /// <exception cref="System.InvalidOperationException">Product Name {productName} has already been added to the contract</exception>
        public void AddVariableValueProduct(Guid productId,
                                            String productName,
                                            String displayText)
        {
            Guard.ThrowIfNullOrEmpty(productName, typeof(ArgumentNullException), "Product Name must not be null or empty");
            Guard.ThrowIfNullOrEmpty(displayText, typeof(ArgumentNullException), "Product Display Text must not be null or empty");

            // Check product not already added
            if (this.Products.Any(p => p.Name == productName))
            {
                throw new InvalidOperationException($"Product Name {productName} has already been added to the contract");
            }

            VariableValueProductAddedToContractEvent variableValueProductAddedToContractEvent =
                new VariableValueProductAddedToContractEvent(this.AggregateId, this.EstateId, productId, productName, displayText);

            this.ApplyAndAppend(variableValueProductAddedToContractEvent);
        }
Beispiel #2
0
 /// <summary>
 /// Handles the specific domain event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 private async Task HandleSpecificDomainEvent(VariableValueProductAddedToContractEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.AddContractProduct(domainEvent, cancellationToken);
 }