public void InsertDebitCreditEntries(LedgerEntry debitEntry, LedgerEntry creditEntry)
        {
            if (debitEntry == null)
            {
                throw new ArgumentNullException(nameof(debitEntry));
            }
            if (creditEntry == null)
            {
                throw new ArgumentNullException(nameof(creditEntry));
            }
            var uof = _uofFactory.GetUnitOfWork(_context);

            uof.AddEntry(debitEntry);
            uof.AddEntry(creditEntry);
            uof.DebitAccount(debitEntry.AccountId, debitEntry.EntryValue);
            uof.CreditAccount(creditEntry.AccountId, -creditEntry.EntryValue);
            _context.SaveChanges();
        }
Exemple #2
0
        public void Save(Account account)
        {
            if (account.AccountId == 0)
            {
                _context.Accounts.Add(account);
            }
            else
            {
                var existingAccount = _context.Accounts.Single(acc => acc.AccountId == account.AccountId);
                _mapper.Map(account, existingAccount);
            }

            _context.SaveChanges();
        }
        public void SeedContext(ContabilidadDbContext context)
        {
            context.Database.EnsureCreated();
            if (context.Accounts.Any())
            {
                return;
            }

            var accounts = new List <Account>();

            accounts.AddRange(GetGroup1());

            context.Accounts.AddRange(accounts);
            context.SaveChanges();
        }
 public void Save(JournalEntryGroupPreset journalEntryPreset)
 {
     _context.JournalEntryGroupPresets.Add(journalEntryPreset);
     _context.SaveChanges();
 }