private void AddToDatabase() { using (EconomyContext context = new EconomyContext()) { Bill bill = new Bill() { id = 2, date = DateTime.Now, money = 733, name = "market", quantity = 2 }; context.Bills.Add(bill); context.SaveChanges(); } }
public static bool AddBill(Bill bill) { using (var ctx = new EconomyContext()) { try { ctx.Bills.Add(bill); ctx.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public static bool SaveMonthlyBill(MonthlyBill bill) { using (var ctx = new EconomyContext()) { try { ctx.MonthlyBills.Attach(bill); ctx.Entry(bill).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }