public ActionResult Create([Bind(Include = "ID,name,amount")] Budget budget) { if (ModelState.IsValid) { db.Budgets.Add(budget); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(budget)); }
public static void SeedDatabase(BudgetDbContext context, IColorGenerator colorGenerator) { context.Database.EnsureCreated(); if (!context.Categories.Any()) { context.Categories.AddRange(GetCategoriesToSeed(colorGenerator)); context.SaveChanges(); } }
public bool EnterTransaction(EnterTransaction transaction) { var newTransaction = new Transaction() { Date = transaction.Date, Account = transaction.Account, Category = transaction.Category, Description = transaction.Description, Value = transaction.Value, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new BudgetDbContext()) { ctx.Transactions.Add(newTransaction); return(ctx.SaveChanges() == 1); } }
public int Complete() { return(_context.SaveChanges()); }
public bool Save() { return(_budgetDbContext.SaveChanges() >= 0); }
public int Commit() { return(_db.SaveChanges()); }
public void add(Budget budgets) { _context.Budget.Add(budgets); _context.SaveChanges(); }
public static void EnsureSeedDataForContext(this BudgetDbContext context) { if (context.Accounts.Any()) { return; } var accounts = new List <Account>() { new Account() { Name = "Gaver Jul", Description = "Julegaver", SubAccounts = new List <SubAccount>() { new SubAccount() { Name = "Mor", Description = "", PostingLines = new List <PostingLine>() { new PostingLine() { Description = "Creme", Location = "Matas", Amount = 175, Created = DateTime.Now }, new PostingLine() { Description = "Bog - Claire Breichter", Location = "Arnold Busk", Amount = 244.50m, Created = DateTime.Now }, } }, new SubAccount() { Name = "Far", Description = "", PostingLines = new List <PostingLine>() { new PostingLine() { Description = "Pibe", Location = "Østerbro Tobaksforretning", Amount = 110, Created = DateTime.Now }, new PostingLine() { Description = "Tegnebog", Location = "Magasin", Amount = 488.25m, Created = DateTime.Now } } }, new SubAccount() { Name = "Bror", Description = "", PostingLines = new List <PostingLine>() { new PostingLine() { Description = "Svæveflyver", Location = "Lyngby Hobby", Amount = 799, Created = DateTime.Now } } }, } }, new Account() { Name = "Gaver Fødselsdage", Description = "Fødselsdagsgaver", SubAccounts = new List <SubAccount>() { } }, new Account() { Name = "Ferier", Description = "Diverse faste ferier og udflugter", SubAccounts = new List <SubAccount>() { } }, new Account() { Name = "Tøj", Description = "Tøj budget", SubAccounts = new List <SubAccount>() { } }, new Account() { Name = "Husholdning", Description = "Dagligt forbrug: mad, cigaretter, personlig pleje mm", SubAccounts = new List <SubAccount>() { } }, new Account() { Name = "Festivitas", Description = "Diverse festivitas afholdt for vores penge", SubAccounts = new List <SubAccount>() { } }, }; context.Accounts.AddRange(accounts); context.SaveChanges(); }
public virtual void Save() { _db.SaveChanges(); }