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