public ActionResult AddNewGoalCatalog(GoalCatalog model) { ViewBag.SubjectId = model.GC_SubjectsId; List <GoalCatalog> allGoalCatalog = GoalCatalog.GetAllParents(model.GC_SubjectsId); allGoalCatalog.Insert(0, new GoalCatalog() { Id = -1, TextGoal = "NONE" }); ViewBag.AllGoals = new SelectList(allGoalCatalog, "Id", "TextGoal"); ViewBag.AllSubjects = new SelectList(GC_Subjects.GetAll(), "Id", "Name"); ViewBag.AlreadyExists = false; if (ModelState.IsValid) { bool isAdded = GoalCatalog.AddNew(model.ParentGoalCatalogId != -1 ? model.ParentGoalCatalogId : null, model.GC_SubjectsId, model.TextGoal, ApplicationHelper.LoggedUserId); if (isAdded) { return(RedirectToAction("Index", new { id = model.GC_SubjectsId })); } return(View(model)); } else { return(View(model)); } }
public ActionResult AddNewGoalCatalog(int subjectId) { ViewBag.SubjectId = subjectId; List <GC_Subjects> _subjects = GC_Subjects.GetAll().Where(a => a.Id == subjectId).ToList(); ViewBag.AllSubjects = new SelectList(_subjects, "Id", "Name"); List <GoalCatalog> allGoalCatalog = GoalCatalog.GetAllParents(subjectId); allGoalCatalog.Insert(0, new GoalCatalog() { Id = -1, TextGoal = "NONE" }); ViewBag.AllGoals = new SelectList(allGoalCatalog, "Id", "TextGoal"); GoalCatalog _item = new GoalCatalog(); return(View(_item)); }