Example #1
0
        public void PerformInitialize()
        {
            //SqlCeEngine engine = new SqlCeEngine("Data Source = AdventureWorks.sdf");
            //engine.Shrink();

            var context = new CashBookContainer();
            //context.ContextOptions.UseLegacyPreserveChangesBehavior
        }
 protected void Commit(CashBookContainer context)
 {
     context.SaveChanges();
 }
        private decimal GetPreviousBalance(CashBookContainer context, DateTime currentDate, long selectedCashBookId)
        {
            //get all the previous registers
            var previousRegisters = context.DailyCashBooks.Where(p => p.Data < currentDate && p.RegistruCasaId == selectedCashBookId).ToList();
            decimal totalSum = 0;
            previousRegisters.ForEach(p => totalSum += p.DeltaBalance);

            //take the initial balance of the cashbook into account
            var currentCashBook = context.UserCashBooks.FirstOrDefault(p => p.Id == selectedCashBookId);
            if (currentCashBook.InitialBalanceDate < currentDate)
            {
                totalSum += currentCashBook.InitialBalance;
            }
            return totalSum;
        }
 private CashBookEntry GetCashBookEntry(long id, CashBookContainer context)
 {
     return context.CashBookEntries.FirstOrDefault(p => p.Id == id);
 }
 private UserCashBook GetCashBook(long id, CashBookContainer context)
 {
     return context.UserCashBooks.FirstOrDefault(p => p.Id == id);
 }