Exemple #1
0
        public void Pay(MakePaymentApplicationCommand makePaymentApplicationCommand)
        {
            //Create Domain Command from Application Command
            var processPaymentDomainCommand = ProcessPaymentDomainCommand.CreateFrom(makePaymentApplicationCommand);

            //Initialize Domain Model
            PaymentRequest paymentRequestDomainModel = new PaymentRequest();

            //Populate Domain Values, Validate Business Logic on Domain Model using Domain Command
            paymentRequestDomainModel.ProcessPaymentRequest(processPaymentDomainCommand);

            //Use third party or internal api to transfer money between accounts
            ///var successfullyProcessedPayments = _transferMoneyService.ProcessPayments(new PaymentsDto(){...})

            //update Domain Model state
            paymentRequestDomainModel.AddProcessPaymentEvent(/*successfullyProcessedPayments*/);

            //Save Domain Model state to Database
            _paymentRequestRepository.Create(paymentRequestDomainModel);
        }