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

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