public JsonResult Edit(int curriculumChapterId, CreateCurriculumChapterModel model)
        {
           try {
            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterId);
            model.SetTimeline = true;
            curriculumChapter.StartDate = model.StartDate;
            curriculumChapter.EndDate = model.EndDate;

            AddValidationErrorsToModelState(Validator.ValidateCurriculumChapter(curriculumChapter).Errors);

            if (ModelState.IsValid)
            {
                Storage.UpdateCurriculumChapter(curriculumChapter);
                return Json(new { success = true, curriculumChapterId = curriculumChapterId, 
                   curriculumChapterRow = PartialViewAsString("CurriculumChapterRow", new ViewCurriculumChapterModel {
                      Id = curriculumChapterId,
                      CurriculumRef = curriculumChapter.CurriculumRef,
                      ChapterName = curriculumChapter.Chapter.Name,
                      HaveTimelines = model.SetTimeline,
                      StartDate = curriculumChapter.StartDate.ToString(),
                      EndDate = curriculumChapter.EndDate.ToString()
                   }),
                   curriculumInfo = new { Id = curriculumChapter.CurriculumRef, IsValid = Storage.GetCurriculum(curriculumChapter.CurriculumRef).IsValid }
                });
            }
              return Json(new {success = false, curriculumChapterId = curriculumChapterId, html = PartialViewAsString("Edit", model)});
           } catch (Exception ex) {
              return Json(new { success = false, html = ex.Message });
           }
        }
        public ActionResult Edit(int curriculumChapterId)
        {
            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterId);
            var curriculum = Storage.GetCurriculum(curriculumChapter.CurriculumRef);
            var discipline = Storage.GetDiscipline(curriculum.DisciplineRef);
            var group = Storage.GetGroup(curriculum.UserGroupRef);
            var model = new CreateCurriculumChapterModel(curriculumChapter.StartDate, curriculumChapter.EndDate);

            Session["CurriculumId"] = curriculumChapter.CurriculumRef;
            ViewData["GroupName"] = group != null ? group.Name : string.Empty;
            ViewData["DisciplineName"] = discipline.Name;
            
            return PartialView(model);
        }
        public ActionResult Edit(int curriculumChapterId, CreateCurriculumChapterModel model)
        {
            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterId);
            curriculumChapter.StartDate = model.SetTimeline ? model.StartDate : (DateTime?)null;
            curriculumChapter.EndDate = model.SetTimeline ? model.EndDate : (DateTime?)null;

            AddValidationErrorsToModelState(Validator.ValidateCurriculumChapter(curriculumChapter).Errors);

            if (ModelState.IsValid)
            {
                Storage.UpdateCurriculumChapter(curriculumChapter);
                return RedirectToRoute("CurriculumChapters", new { action = "Index", CurriculumId = Session["CurriculumId"] });
            }
            return View(model);
        }
        public ActionResult Edit(int curriculumChapterId)
        {
            LoadValidationErrors();

            var curriculumChapter = Storage.GetCurriculumChapter(curriculumChapterId);
            var curriculum = Storage.GetCurriculum(curriculumChapter.CurriculumRef);
            var discipline = Storage.GetDiscipline(curriculum.DisciplineRef);
            var group = Storage.GetGroup(curriculum.UserGroupRef);
            var model = new CreateCurriculumChapterModel(curriculumChapter.StartDate, curriculumChapter.EndDate);

            Session["CurriculumId"] = curriculumChapter.CurriculumRef;
            ViewData["GroupName"] = group.Name;
            ViewData["DisciplineName"] = discipline.Name;
            return View(model);
        }