Ejemplo n.º 1
0
 public IHttpActionResult Submit(SubmitPaymentCommand command)
 {
     return Ok(_paymentService.Submit(command));
 }
Ejemplo n.º 2
0
 public BankOperationModel Submit(SubmitPaymentCommand command)
 {
     EnsureIsValid(command);
     EnsureIsSecure<SubmitPaymentCommand, CardSecurityValidator>(command);
     try
     {
         var userCard = _deps.UserCards.SurelyFind(command.FromCardId);
         var template = _deps.PaymentTemplates.SurelyFind(command.TemplateCode);
         var payment = _deps.CardPaymentFactory.Create(userCard, template, command.Form);
         var paymentLink = new PaymentTransactionLink(payment.Withdrawal, payment.Order);
         _deps.Payments.Create(payment);
         _deps.PaymentTransactionLinks.Create(paymentLink);
         var userOperation = new UserBankOperation(payment, Identity.User);
         _deps.UserBankOperations.Create(userOperation);
         Commit();
         var model = payment.ToModel<BankOperation, BankOperationModel>();
         Publish(new OperationProgressEvent(Operation.Id, model));
         return model;
     }
     catch (Exception ex)
     {
         throw new ServiceException("Can't submit payment.", ex);
     }
 }