コード例 #1
0
        private List <PassedInternalChecksReadyToTakePayment> CheckPassingValidationRules(ProcessPaymentDomainCommand processPaymentCommand)
        {
            if (processPaymentCommand == null || processPaymentCommand.PaymentRequests == null || !processPaymentCommand.PaymentRequests.ToList().Any())
            {
                return(new List <PassedInternalChecksReadyToTakePayment>());
            }

            //checking validation logic:
            // - Minimum amount is £1.00.
            // - Maximum amount is £20,000,000.00.
            foreach (var paymentRequest in processPaymentCommand.PaymentRequests)
            {
                if (paymentRequest.Amount < 1 || paymentRequest.Amount > 20000000.00)
                {
                    InternalValidationFailedPayments.Add(new InternalValidationFailedPayment()
                    {
                        Code = paymentRequest.Code, Name = paymentRequest.Name, Reference = paymentRequest.Reference, Amount = paymentRequest.Amount
                    });
                    continue;
                }
                PassedInternalChecksReadyToTakePayments.Add(new PassedInternalChecksReadyToTakePayment()
                {
                    Code = paymentRequest.Code, Name = paymentRequest.Name, Reference = paymentRequest.Reference, Amount = paymentRequest.Amount
                });
            }

            return(PassedInternalChecksReadyToTakePayments);
        }
コード例 #2
0
 public void AddProcessPaymentEvent(/*ProcessedPayments processedPayments*/)
 {
     //from processedPayments assign: successfulPayments, FailedPayments and FraudCheckFlaggedOnHoldManualInterventionRequiredPayments for persistance:
     if (PassedInternalChecksReadyToTakePayments.Any())
     {
         SuccessfulPayments = this.PassedInternalChecksReadyToTakePayments.Select(x => new SuccessfulPayment()
         {
             Code = x.Code, Name = x.Name, Reference = x.Reference, Amount = x.Amount
         }).ToList();
     }
     if (InternalValidationFailedPayments.Any())
     {
         FailedPayments = this.InternalValidationFailedPayments.Select(x => new FailedPayment()
         {
             Code = x.Code, Name = x.Name, Reference = x.Reference, Amount = x.Amount
         }).ToList();
     }
     //Raise Domain Event ProcessedPayments: (for any interested other bounded contexts that might have the requirement to build read model projections from this event (surfaced through a domain event handler with an integration event publish).
     //RaiseDomainEvent(_processedPaymentEvent);
 }