//Following 2 functions - DoPayment and MakePayment do the same functionality - in 2 different styles public async Task <Payment> DoPayment(PaymentRequest paymentRequest) { //style -> RETURN errors as exceptions //validate the accounts //these calls themselves throw exceptions if the accounts are not valid await _bankClient.ValidateAccount(paymentRequest.payee.accountNumber, paymentRequest.payee.ifscCode); await _bankClient.ValidateAccount(paymentRequest.beneficiary.accountNumber, paymentRequest.beneficiary.ifscCode); //a hard coded sample check representing a biz logic if (paymentRequest.amount > 1000000) { throw new ProcessingException("Amount exceeded permitted limit", null, paymentRequest); } //create payment entry with initial status "InProgress" Payment payment = new Payment(paymentRequest.beneficiary.name, paymentRequest.beneficiary.accountNumber, paymentRequest.beneficiary.ifscCode, paymentRequest.payee.name, paymentRequest.payee.accountNumber, paymentRequest.payee.ifscCode, paymentRequest.amount, PaymentStatus.InProgress); _context.Payments.Add(payment); await _context.SaveChangesAsync(); //TODO - do the transaction { //1. debit payee //2. credit beneficiary //3. update status in database payment._status = PaymentStatus.Completed; _context.Payments.Update(payment); await _context.SaveChangesAsync(); //END TODO - do the transaction //} return(payment); }