Пример #1
0
 public void Remove(ExpenseType expenseType)
 {
     using (ExpenseContext _expenseContext = new ExpenseContext())
     {
         _expenseContext.ExpenseTypes.Remove(expenseType);
     }
 }
Пример #2
0
 public List <ExpenseType> GetAll()
 {
     using (ExpenseContext _expenseContext = new ExpenseContext())
     {
         return(_expenseContext.ExpenseTypes.ToList());
     }
 }
Пример #3
0
 public ExpenseType Get(int id)
 {
     using (ExpenseContext _expenseContext = new ExpenseContext())
     {
         return(_expenseContext.ExpenseTypes.Where(x => x.Id == id).FirstOrDefault());
     }
 }
Пример #4
0
        public Expense Get(int id)
        {
            using (ExpenseContext db = new ExpenseContext())

                return(db.Expenses
                       .Where(x => x.Id == id)
                       .FirstOrDefault());
        }
Пример #5
0
 public void Remove(Expense entity)
 {
     using (ExpenseContext db = new ExpenseContext())
     {
         db.Expenses.Remove(entity);
         db.SaveChanges();
     }
 }
Пример #6
0
 public void Add(Expense entity)
 {
     using (ExpenseContext db = new ExpenseContext())
     {
         db.Expenses.Add(entity);
         db.SaveChanges();
     }
 }
Пример #7
0
 public void Add(ExpenseType expenseType)
 {
     using (ExpenseContext _expenseContext = new ExpenseContext())
     {
         _expenseContext.ExpenseTypes.Add(expenseType);
         _expenseContext.SaveChanges();
     }
 }
Пример #8
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();
            }
        }
Пример #9
0
 public List <Expense> GetAll()
 {
     using (ExpenseContext db = new ExpenseContext())
         return(db.Expenses.Include("ExpenseType").ToList());
 }