public ActionResult InsertBudgetGoal(BudgetGoalModelView model) { //repopulate the dropdownlist model.category = GetSelectListItems(GetAllCategories()); BudgetGoal newBudgetGoal = new BudgetGoal(); newBudgetGoal = model.budgetGoal; //insert for next month newBudgetGoal.ClientID = CLIENT_ID; newBudgetGoal.BudgetPointValue = 25; if (newBudgetGoal.BudgetGoalID == 0) //create new category { newBudgetGoal.Month = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); newBudgetGoal.Status = "A"; dbContext.BudgetGoals.Add(newBudgetGoal); } else //we're just updating a current budget { dbContext.Entry(newBudgetGoal).State = EntityState.Modified; } //ignore validation errors on Month and BudgetGoalId ---temporary fix? ModelState.Remove("budgetGoal.Month"); ModelState.Remove("budgetGoal.BudgetGoalId"); if (ModelState.IsValid) { dbContext.SaveChanges(); return(RedirectToAction("index")); } return(View(model)); }
public ActionResult inactivateBudget(int?id) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Home")); } else { CLIENT_ID = int.Parse(Session["UserID"].ToString()); } if (id == null) { return(RedirectToAction("index")); } BudgetGoal bg = dbContext.BudgetGoals.Where(x => x.ClientID == CLIENT_ID && x.BudgetGoalID == id).FirstOrDefault(); if (bg == null) { return(RedirectToAction("index")); } else { bg.Status = "I"; dbContext.SaveChanges(); return(RedirectToAction("index")); } }