public ActionResult Index(BudgetViewModel model) { var budget = new Budget(); model.CopyProperties(budget); budget.HouseholdId = GetHouseholdIdForCurrentUser(); Service.Budgets.Upsert(budget); // Save the map var map = new BudgetCategoryMap(); map.BudgetId = budget.Id; map.CategoryId = model.CategoryId; Service.BudgetCategoryMaps.Upsert(map); model.CurrentBudgets = Service.Budgets.GetAllForHousehold(true); var categories = Service.Categories.GetAllForHousehold(true); model.Categories = new SelectList(categories, "Name", "Name"); return PartialView("BudgetListPartial", new BudgetListViewModel(model.CurrentBudgets)); }
public ActionResult EditBudget(Budget budget) { budget.IsNew = false; Service.Budgets.Upsert(budget); return RedirectToAction("Index"); }