|
@@ -64,7 +64,7 @@ public interface IMainDbService
|
|
|
Task<Dictionary<string, decimal>> GetTransactionPeriodEnergy(int transactionId);
|
|
|
|
|
|
Task<bool> UpdateCustomId(string customId, string chargeboxId);
|
|
|
-
|
|
|
+ Task SetTransactionBillingDone(int txId, decimal cost, string receipt);
|
|
|
}
|
|
|
|
|
|
public class MainDbService : IMainDbService
|
|
@@ -560,6 +560,29 @@ public class MainDbService : IMainDbService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public async Task SetTransactionBillingDone(int txId, decimal cost, string receipt)
|
|
|
+ {
|
|
|
+ using var db = await contextFactory.CreateDbContextAsync();
|
|
|
+ TransactionRecord transaction = await db.TransactionRecord.Where(x => x.Id == txId).FirstOrDefaultAsync();
|
|
|
+ if (transaction is null)
|
|
|
+ {
|
|
|
+ logger.LogTrace("Tx is empty");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ transaction.Cost = cost;
|
|
|
+ transaction.Receipt = receipt;
|
|
|
+ transaction.BillingDone = true;
|
|
|
+
|
|
|
+ db.ChangeTracker.AutoDetectChangesEnabled = false;
|
|
|
+ //db.Configuration.ValidateOnSaveEnabled = false;
|
|
|
+ db.TransactionRecord.Attach(transaction);
|
|
|
+ db.Entry(transaction).Property(x => x.Cost).IsModified = true;
|
|
|
+ db.Entry(transaction).Property(x => x.Receipt).IsModified = true;
|
|
|
+ db.Entry(transaction).Property(x => x.BillingDone).IsModified = true;
|
|
|
+ await db.SaveChangesAsync();
|
|
|
+ }
|
|
|
+
|
|
|
private void InitUpdateConnectorStatusHandler()
|
|
|
{
|
|
|
if (statusNotificationHandler is not null)
|