public IActionResult EditAutoRefreshOptions(int customisationId) { var centreId = User.GetCentreId(); var categoryId = User.GetAdminCourseCategoryFilter(); var courseDetails = courseService.GetCourseDetailsFilteredByCategory( customisationId, centreId, categoryId ) !; var courseOptions = GetCourseOptionsSelectList(customisationId, courseDetails.RefreshToCustomisationId); var model = new EditAutoRefreshOptionsViewModel(courseDetails, customisationId, courseOptions); return(View(model)); }
public IActionResult EditAutoRefreshOptions( int customisationId, EditAutoRefreshOptionsFormData formData ) { if (!ModelState.IsValid) { var courseOptions = GetCourseOptionsSelectList(customisationId, formData.RefreshToCustomisationId); var model = new EditAutoRefreshOptionsViewModel(formData, customisationId, courseOptions); return(View(model)); } var data = TempData.Peek <EditLearningPathwayDefaultsData>() !; var autoRefreshMonths = GetIntegerFromStringOrConvertToZeroIfNull(formData.AutoRefreshMonths); var completeWithinMonthsInt = GetIntegerFromStringOrConvertToZeroIfNull(data.LearningPathwayDefaultsModel.CompleteWithinMonths); var validityMonthsInt = GetIntegerFromStringOrConvertToZeroIfNull(data.LearningPathwayDefaultsModel.ValidityMonths); var refreshToCustomisationId = formData.RefreshToCustomisationId ?? 0; courseService.UpdateLearningPathwayDefaultsForCourse( customisationId, completeWithinMonthsInt, validityMonthsInt, data.LearningPathwayDefaultsModel.Mandatory, data.LearningPathwayDefaultsModel.AutoRefresh, refreshToCustomisationId, autoRefreshMonths, formData.ApplyLpDefaultsToSelfEnrol ); return(RedirectToAction("Index", new { customisationId })); }