public async Task <IActionResult> Payed(PayedInput input) { PayedInfo info = new PayedInfo(input.PayedDesc, input.Payer, DateTime.Now, input.PayDecimal, input.OrderId); using (var transcation = _paymentDbContext.Database.BeginTransaction(_capBus, true)) { try { await _paymentDbContext.AddAsync(info); _capBus.Publish("Payment.services.Payed", info); var result = await _paymentDbContext.SaveChangesAsync(); // transcation.Commit(); } catch (Exception e) { await transcation.RollbackAsync(); return(BadRequest()); } return(Ok()); } }
public async Task <Payment> AddPaymentAsync(Payment payment) { await _paymentDbContext.AddAsync(payment); if (!await SaveChangesAsync()) { throw new DbUpdateException("Database failure"); } return(payment); }