Exemple #1
0
        public ActionResult Create(int stageId, CreateThemeModel model)
        {
            try
            {
                Theme theme = new Theme
                {
                    CourseRef    = model.CourseId == Constants.NoCourseId ? (int?)null : 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;
            }
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
        public async Task <CreateThemeResult> CreateAsync(CreateThemeModel createThemeModel)
        {
            var validResult = await createThemeModelValidator.ValidateAsync(createThemeModel);

            if (!validResult.Succeed)
            {
                return(new CreateThemeResult(validResult));
            }
            var model = mapper.Map <ThemeModel>(createThemeModel);
            await themesCrudService.CreateAsync(model);

            var result = new CreateThemeResult
            {
                CreatedThemeId   = model.Id,
                CreatedThemeName = model.Name
            };

            return(result);
        }
Exemple #5
0
        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;
            }
        }