public ActionResult Create(int stageId, CreateThemeModel model) { try { Theme theme = new Theme { CourseRef = model.CourseId, StageRef = model.StageId, ThemeTypeRef = model.ThemeTypeId, Name = model.ThemeName }; AddValidationErrorsToModelState(Validator.ValidateTheme(theme).Errors); if (ModelState.IsValid) { Storage.AddTheme(theme); return RedirectToAction("Index", new { StageId = model.StageId }); } else { SaveValidationErrors(); return RedirectToAction("Create"); } } catch (Exception e) { throw e; } }
public ActionResult Create(int stageId) { try { LoadValidationErrors(); Stage stage = Storage.GetStage(stageId); var model = new CreateThemeModel(stageId, Storage.GetCourses(), 0, Storage.GetThemeTypes(), 0, ""); ViewData["CurriculumName"] = stage.Curriculum.Name; ViewData["StageName"] = stage.Name; return View(model); } catch (Exception e) { throw e; } }
public ActionResult Edit(int themeId) { try { LoadValidationErrors(); var theme = Storage.GetTheme(themeId); var model = new CreateThemeModel(theme.StageRef, Storage.GetCourses(), theme.CourseRef, Storage.GetThemeTypes(), theme.ThemeTypeRef, theme.Name); ViewData["CurriculumName"] = theme.Stage.Curriculum.Name; ViewData["StageName"] = theme.Stage.Name; ViewData["ThemeName"] = theme.Name; return View(model); } catch (Exception e) { throw e; } }
public ActionResult Edit(int themeId, CreateThemeModel model) { try { Theme theme = Storage.GetTheme(themeId); theme.CourseRef = model.CourseId; theme.ThemeTypeRef = model.ThemeTypeId; theme.Name = model.ThemeName; AddValidationErrorsToModelState(Validator.ValidateTheme(theme).Errors); if (ModelState.IsValid) { Storage.UpdateTheme(theme); return RedirectToRoute("Themes", new { action = "Index", StageId = theme.StageRef }); } else { SaveValidationErrors(); return RedirectToAction("Edit"); } } catch (Exception e) { throw e; } }