This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Saga Events | |
| public record OrderCreatedEvent(Guid OrderId, int ProductId, int Quantity, decimal Amount, string CustomerId); | |
| public record StockReservedEvent(Guid OrderId, int ProductId, int Quantity); | |
| public record StockReservationFailedEvent(Guid OrderId, string Reason); | |
| public record OrderConfirmedEvent(Guid OrderId); | |
| public record OrderCancelledEvent(Guid OrderId, string Reason); | |
| public record StockReleaseRequestedEvent(Guid OrderId, int ProductId, int Quantity); | |
| public class OutboxMessage | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ITransactionParticipant | |
| { | |
| Task<PrepareResult> PrepareAsync(Guid transactionId, TransactionContext context); | |
| Task CommitAsync(Guid transactionId); | |
| Task RollbackAsync(Guid transactionId); | |
| } | |
| public enum PrepareResult | |
| { | |
| Prepared, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SaleDocument | |
| { | |
| .... | |
| public decimal GetDiscerpancyAmount(ISpecification<SaleDocument> spec) => | |
| spec.IsSatisfiedBy(this) ? ConfirmedPrice - DocumentNetPrice : 0; | |
| .... | |
| } | |
| public class SaleDocumentService | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public decimal GetDiscerpancyAmount(ISpecification<SaleDocument> spec) => | |
| spec.IsSatisfiedBy(this) ? ConfirmedPrice - DocumentNetPrice : 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OrderWithoutInvoiceSpecification : Specification<SaleDocument> | |
| { | |
| ... | |
| } | |
| public class ApprovedOrderWithoutInvoiceSpecification : AndSpecification<SaleDocument> | |
| { | |
| public ApprovedOrderWithoutInvoiceSpecification() | |
| : base(new ApprovedOrderSpecification(), new OrderWithoutInvoiceSpecification()) | |
| {} | |
| } |