public async Task AddPaymentTransferAsync(PaymentTransferDto paymentTransfer) { using (var context = _contextFactory.CreateDataContext()) { var historyEntity = TransactionHistoryEntity.CreateForPaymentTransferTokensReservation(paymentTransfer); var transferEntity = PaymentTransferEntity.Create(paymentTransfer); var burnRule = await context.BurnRules.FindAsync(paymentTransfer.BurnRuleId); if (burnRule != null && burnRule.BurnRuleName != paymentTransfer.BurnRuleName) { burnRule.BurnRuleName = paymentTransfer.BurnRuleName; } if (burnRule == null) { burnRule = BurnRuleEntity.Create(paymentTransfer.BurnRuleId, paymentTransfer.BurnRuleName); } transferEntity.BurnRule = burnRule; context.PaymentTransfers.Add(transferEntity); context.TransactionHistories.Add(historyEntity); await context.SaveChangesAsync(); } }