public async Task AddDocumentAggregate(C21DocumentAggregate documentAggregate) { documentAggregate.RenumberDocumentId(await GetNextDocumentId(50), await GetNextAccountRecordtId(50), await GetNextVatRegistertId(50)); if (documentAggregate != null) { using (var db = new SageDb("Db")) { await db.BeginTransactionAsync(); try { await db.InsertAsync(documentAggregate.Document); await db.BulkCopyAsync(documentAggregate.VatRegisters); await db.BulkCopyAsync(documentAggregate.AccountingRecords); await db.CommitTransactionAsync(); } catch (Exception ex) { await db.RollbackTransactionAsync(); throw ex; } } } }
public async Task AddContractorsAsync(List <C21Contractor> c21Contractors) { using (var db = new SageDb("Db")) { foreach (var contractor in c21Contractors) { try { await db.InsertAsync(contractor); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }