コード例 #1
0
        public IActionResult SetCourseDetails(SetCourseDetailsViewModel model)
        {
            var data = multiPageFormService.GetMultiPageFormData <AddNewCentreCourseTempData>(
                MultiPageFormDataFeature.AddNewCourse,
                TempData
                );
            var centreId = User.GetCentreId();

            CourseDetailsValidator.ValidateCustomisationName(
                model,
                ModelState,
                courseService,
                centreId
                );
            CourseDetailsValidator.ResetValueAndClearErrorsOnPasswordIfUnselected(model, ModelState);
            CourseDetailsValidator.ResetValueAndClearErrorsOnEmailIfUnselected(model, ModelState);
            CourseDetailsValidator.ResetValueAndClearErrorsOnOtherCompletionCriteriaIfUnselected(model, ModelState);

            if (!ModelState.IsValid)
            {
                return(View("AddNewCentreCourse/SetCourseDetails", model));
            }

            data !.CourseDetailsData = model.ToCourseDetailsTempData();
            multiPageFormService.SetMultiPageFormData(data, MultiPageFormDataFeature.AddNewCourse, TempData);

            return(RedirectToAction("SetCourseOptions"));
        }
コード例 #2
0
        public IActionResult SaveCourseDetails(
            int customisationId,
            EditCourseDetailsFormData formData
            )
        {
            var centreId = User.GetCentreId();

            CourseDetailsValidator.ValidateCustomisationName(
                formData,
                ModelState,
                courseService,
                centreId,
                customisationId
                );
            CourseDetailsValidator.ResetValueAndClearErrorsOnPasswordIfUnselected(formData, ModelState);
            CourseDetailsValidator.ResetValueAndClearErrorsOnEmailIfUnselected(formData, ModelState);
            CourseDetailsValidator.ResetValueAndClearErrorsOnOtherCompletionCriteriaIfUnselected(formData, ModelState);

            if (!ModelState.IsValid)
            {
                var model = new EditCourseDetailsViewModel(formData, customisationId);
                return(View("EditCourseDetails", model));
            }

            var tutCompletionThreshold =
                formData.TutCompletionThreshold == null ? 0 : int.Parse(formData.TutCompletionThreshold);
            var diagCompletionThreshold =
                formData.DiagCompletionThreshold == null ? 0 : int.Parse(formData.DiagCompletionThreshold);

            courseService.UpdateCourseDetails(
                customisationId,
                formData.CustomisationName !,
                formData.Password !,
                formData.NotificationEmails !,
                formData.IsAssessed,
                tutCompletionThreshold,
                diagCompletionThreshold
                );

            return(RedirectToAction("Index", new { customisationId }));
        }