public ActionResult Create(Saving saving) { if (ModelState.IsValid) { db.Savings.Add(saving); db.SaveChanges(); return RedirectToAction("Index"); } return View(saving); }
public bool AddSaving(Saving newSaving) { try { _ctx.Savings.Add(newSaving); return(true); } catch (Exception) { //TODO log this error return(false); } }
public bool AddSaving(Saving newSaving) { try { _ctx.Savings.Add(newSaving); return true; } catch (Exception) { //TODO log this error return false; } }
protected override void Seed(BudgetCalculatorContext context) { base.Seed(context); #if DEBUG if (context.Budgets.Count() == 0) { var budget = new Budget() { Name = "Test Budget", Amount = 10.00m }; context.Budgets.Add(budget); } if (context.Savings.Count() == 0) { var saving = new Saving() { Name = "Test Saving", Amount = 50.00m }; context.Savings.Add(saving); } if (context.Entries.Count() == 0) { var entry = new Entry() { Date = DateTime.Now, Description = "Test Entry", BudgetCategory = "Test Budget", Amount = 5.00m }; context.Entries.Add(entry); } try { context.SaveChanges(); } catch (Exception ex) { var msg = ex.Message; throw; } #endif }
public ActionResult Edit(Saving saving) { if (ModelState.IsValid) { db.Entry(saving).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(saving); }
public bool RemoveSaving(Saving saving) { _ctx.Savings.Remove(saving); return(true); }
public bool RemoveSaving(Saving saving) { _ctx.Savings.Remove(saving); return true; }