private void PlayEvent(TransactionFeeForProductDisabledEvent domainEvent) { // Find the product Product product = this.Products.Single(p => p.ProductId == domainEvent.ProductId); TransactionFee transactionFee = product.TransactionFees.Single(t => t.TransactionFeeId == domainEvent.TransactionFeeId); transactionFee.IsEnabled = false; }
public void ContractDomainEventHandler_TransactionFeeForProductDisabledEvent_EventIsHandled() { TransactionFeeForProductDisabledEvent transactionFeeForProductDisabledEvent = TestData.TransactionFeeForProductDisabledEvent; Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>(); ContractDomainEventHandler eventHandler = new ContractDomainEventHandler(estateReportingRepository.Object); Logger.Initialise(NullLogger.Instance); Should.NotThrow(async() => { await eventHandler.Handle(transactionFeeForProductDisabledEvent, CancellationToken.None); }); }
public void TransactionFeeForProductDisabledEvent_CanBeCreated_IsCreated() { TransactionFeeForProductDisabledEvent transactionFeeForProductDisabledEvent = new TransactionFeeForProductDisabledEvent(TestData.ContractId, TestData.EstateId, TestData.ProductId, TestData.TransactionFeeId); transactionFeeForProductDisabledEvent.ShouldNotBeNull(); transactionFeeForProductDisabledEvent.AggregateId.ShouldBe(TestData.ContractId); transactionFeeForProductDisabledEvent.EventId.ShouldNotBe(Guid.Empty); transactionFeeForProductDisabledEvent.ContractId.ShouldBe(TestData.ContractId); transactionFeeForProductDisabledEvent.EstateId.ShouldBe(TestData.EstateId); transactionFeeForProductDisabledEvent.ProductId.ShouldBe(TestData.ProductId); transactionFeeForProductDisabledEvent.TransactionFeeId.ShouldBe(TestData.TransactionFeeId); }
/// <summary> /// Disables the transaction fee. /// </summary> /// <param name="productId">The product identifier.</param> /// <param name="transactionFeeId">The transaction fee identifier.</param> public void DisableTransactionFee(Guid productId, Guid transactionFeeId) { if (this.Products.Any(p => p.ProductId == productId) == false) { throw new InvalidOperationException($"Product Id {productId} is not a valid product on this contract"); } Product product = this.Products.Single(p => p.ProductId == productId); if (product.TransactionFees.Any(f => f.TransactionFeeId == transactionFeeId) == false) { throw new InvalidOperationException($"Transaction Fee Id {transactionFeeId} is not a valid for product {product.Name} on this contract"); } TransactionFeeForProductDisabledEvent transactionFeeForProductDisabledEvent = new TransactionFeeForProductDisabledEvent(this.AggregateId, this.EstateId, productId, transactionFeeId); this.ApplyAndAppend(transactionFeeForProductDisabledEvent); }
/// <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(TransactionFeeForProductDisabledEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.DisableContractProductTransactionFee(domainEvent, cancellationToken); }