public ActionResult Create(int curriculumId, CreateCurriculumAssignmentModel createAssignmentModel) { try { CurriculumAssignment curriculumAssignment = new CurriculumAssignment(); curriculumAssignment.UserGroupRef = createAssignmentModel.GroupId; curriculumAssignment.CurriculumRef = curriculumId; AddValidationErrorsToModelState(Validator.ValidateCurriculumAssignment(curriculumAssignment).Errors); if (ModelState.IsValid) { Storage.AddCurriculumAssignment(curriculumAssignment); return(RedirectToAction("Index")); } else { SaveValidationErrors(); return(RedirectToAction("Create")); } } catch (Exception e) { throw e; } }
public ActionResult Edit(int curriculumAssignmentId, CreateCurriculumAssignmentModel editAssignmentModel) { try { CurriculumAssignment curriculumAssignment = new CurriculumAssignment(); curriculumAssignment.UserGroupRef = editAssignmentModel.GroupId; curriculumAssignment.Id = curriculumAssignmentId; AddValidationErrorsToModelState(Validator.ValidateCurriculumAssignment(curriculumAssignment).Errors); if (ModelState.IsValid) { Storage.UpdateCurriculumAssignment(curriculumAssignment); return(RedirectToRoute("CurriculumAssignments", new { action = "Index", CurriculumId = Session["CurriculumId"] })); } else { SaveValidationErrors(); return(RedirectToAction("Create")); } } catch (Exception e) { throw e; } }
public ActionResult Create(int curriculumId) { try { LoadValidationErrors(); IEnumerable <Group> groups = Storage.GetNotAssignedGroups(curriculumId); Curriculum curriculum = Storage.GetCurriculum(curriculumId); CreateCurriculumAssignmentModel createAssignmentModel = new CreateCurriculumAssignmentModel(groups, 0); ViewData["CurriculumName"] = curriculum.Name; return(View(createAssignmentModel)); } catch (Exception e) { throw e; } }
public ActionResult Edit(int curriculumAssignmentId) { try { LoadValidationErrors(); CurriculumAssignment curriculumAssignment = Storage.GetCurriculumAssignment(curriculumAssignmentId); int curriculumId = curriculumAssignment.CurriculumRef; Curriculum curriculum = Storage.GetCurriculum(curriculumId); int assignmentGroupId = curriculumAssignment.UserGroupRef; IEnumerable <Group> groups = Storage.GetNotAssignedGroupsWithCurrentGroup(curriculumId, assignmentGroupId); CreateCurriculumAssignmentModel editAssignmentModel = new CreateCurriculumAssignmentModel(groups, assignmentGroupId); Session["CurriculumId"] = curriculumId; ViewData["CurriculumName"] = curriculum.Name; return(View(editAssignmentModel)); } catch (Exception e) { throw e; } }