public ActionResult Create(int chapterId, CreateTopicModel model) { var topic = new Topic { ChapterRef = model.ChapterId, Name = model.TopicName, TestCourseRef = model.BindTestCourse ? model.TestCourseId : (int?)null, TestTopicTypeRef = model.BindTestCourse ? model.TestTopicTypeId : (int?)null, TheoryCourseRef = model.BindTheoryCourse ? model.TheoryCourseId : (int?)null, TheoryTopicTypeRef = model.BindTheoryCourse ? model.TheoryTopicTypeId : (int?)null }; AddValidationErrorsToModelState(Validator.ValidateTopic(topic).Errors); if (ModelState.IsValid) { Storage.AddTopic(topic); return RedirectToAction("Index", new { ChapterId = model.ChapterId }); } else { SaveValidationErrors(); return RedirectToAction("Create"); } }
public ActionResult Create(int chapterId, CreateTopicModel model) { try { Topic topic = new Topic { CourseRef = model.CourseId == Constants.NoCourseId ? (int?)null : model.CourseId, ChapterRef = model.ChapterId, TopicTypeRef = model.TopicTypeId, Name = model.TopicName }; AddValidationErrorsToModelState(Validator.ValidateTopic(topic).Errors); if (ModelState.IsValid) { Storage.AddTopic(topic); return RedirectToAction("Index", new { ChapterId = model.ChapterId }); } else { SaveValidationErrors(); return RedirectToAction("Create"); } } catch (Exception e) { throw e; } }
public ActionResult Create(int chapterId) { LoadValidationErrors(); var chapter = Storage.GetChapter(chapterId); var model = new CreateTopicModel("", chapterId, Storage.GetCourses(), 0, Storage.GetTestTopicTypes(), 0, 0, Storage.GetTheoryTopicTypes(), 0); ViewData["DisciplineName"] = chapter.Discipline.Name; ViewData["ChapterName"] = chapter.Name; return View(model); }
public ActionResult Create(int chapterId) { try { LoadValidationErrors(); Chapter chapter = Storage.GetChapter(chapterId); var model = new CreateTopicModel(chapterId, Storage.GetCourses(), 0, Storage.GetTopicTypes(), 0, ""); ViewData["DisciplineName"] = chapter.Discipline.Name; ViewData["ChapterName"] = chapter.Name; return View(model); } catch (Exception e) { throw e; } }
public ActionResult Edit(int topicId, CreateTopicModel model) { var topic = Storage.GetTopic(topicId); topic.Name = model.TopicName; topic.TestCourseRef = model.BindTestCourse ? model.TestCourseId : (int?)null; topic.TestTopicTypeRef = model.BindTestCourse ? model.TestTopicTypeId : (int?)null; topic.TheoryCourseRef = model.BindTheoryCourse ? model.TheoryCourseId : (int?)null; topic.TheoryTopicTypeRef = model.BindTheoryCourse ? model.TheoryTopicTypeId : (int?)null; AddValidationErrorsToModelState(Validator.ValidateTopic(topic).Errors); if (ModelState.IsValid) { Storage.UpdateTopic(topic); return RedirectToRoute("Topics", new { action = "Index", ChapterId = topic.ChapterRef }); } else { SaveValidationErrors(); return RedirectToAction("Edit"); } }
public ActionResult Edit(int topicId) { LoadValidationErrors(); var topic = Storage.GetTopic(topicId); var model = new CreateTopicModel(topic.Name, topic.ChapterRef, Storage.GetCourses(), topic.TestCourseRef, Storage.GetTestTopicTypes(), topic.TestTopicTypeRef, topic.TheoryCourseRef, Storage.GetTheoryTopicTypes(), topic.TheoryTopicTypeRef); ViewData["DisciplineName"] = topic.Chapter.Discipline.Name; ViewData["ChapterName"] = topic.Chapter.Name; ViewData["TopicName"] = topic.Name; return View(model); }
public ActionResult Edit(int topicId) { try { LoadValidationErrors(); var topic = Storage.GetTopic(topicId); var model = new CreateTopicModel(topic.ChapterRef, Storage.GetCourses(), topic.CourseRef, Storage.GetTopicTypes(), topic.TopicTypeRef, topic.Name); ViewData["DisciplineName"] = topic.Chapter.Discipline.Name; ViewData["ChapterName"] = topic.Chapter.Name; ViewData["TopicName"] = topic.Name; return View(model); } catch (Exception e) { throw e; } }
public ActionResult Edit(int topicId, CreateTopicModel model) { try { Topic topic = Storage.GetTopic(topicId); topic.CourseRef = model.CourseId == Constants.NoCourseId ? (int?)null : model.CourseId; topic.TopicTypeRef = model.TopicTypeId; topic.Name = model.TopicName; AddValidationErrorsToModelState(Validator.ValidateTopic(topic).Errors); if (ModelState.IsValid) { Storage.UpdateTopic(topic); return RedirectToRoute("Topics", new { action = "Index", ChapterId = topic.ChapterRef }); } else { SaveValidationErrors(); return RedirectToAction("Edit"); } } catch (Exception e) { throw e; } }