Example #1
0
 public void Add(Expense entity)
 {
     using (ExpenseContext db = new ExpenseContext())
     {
         db.Expenses.Add(entity);
         db.SaveChanges();
     }
 }
Example #2
0
 public void Remove(Expense entity)
 {
     using (ExpenseContext db = new ExpenseContext())
     {
         db.Expenses.Remove(entity);
         db.SaveChanges();
     }
 }
Example #3
0
 public void Add(ExpenseType expenseType)
 {
     using (ExpenseContext _expenseContext = new ExpenseContext())
     {
         _expenseContext.ExpenseTypes.Add(expenseType);
         _expenseContext.SaveChanges();
     }
 }
Example #4
0
        public void Update(Expense newRecord)
        {
            using (ExpenseContext db = new ExpenseContext())
            {
                var oldRecord = db.Expenses.Where(x => x.Id == newRecord.Id).FirstOrDefault();

                db.Entry(oldRecord).CurrentValues.SetValues(newRecord);

                db.SaveChanges();
            }
        }