Esempio n. 1
0
        public static List <String> GetWarningMessages(this AddEditCourseModel model)
        {
            List <String> messages = new List <String>();

            if (!String.IsNullOrWhiteSpace(model.Url) && !UrlHelper.UrlIsReachable(model.Url))
            {
                messages.Add(String.Format(AppGlobal.Language.GetText("AddEditCourseModel_Edit_UrlNotReachable", "The web address for {0} returns a response that suggests this page may not exist. Please check that the web address entered is correct."), AppGlobal.Language.GetText("AddEditCourseModel_DisplayName_Url", "URL")));
            }
            if (!String.IsNullOrWhiteSpace(model.BookingUrl) && !UrlHelper.UrlIsReachable(model.BookingUrl))
            {
                messages.Add(String.Format(AppGlobal.Language.GetText("AddEditCourseModel_Edit_UrlNotReachable", "The web address for {0} returns a response that suggests this page may not exist. Please check that the web address entered is correct."), AppGlobal.Language.GetText("AddEditCourseModel_DisplayName_BookingUrl", "Booking URL")));
            }

            return(messages);
        }
Esempio n. 2
0
        /// <summary>
        /// Convert an <see cref="AddEditCourseModel"/> to an <see cref="Course"/>.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="db">
        /// The db.
        /// </param>
        /// <returns>
        /// The <see cref="Course"/>.
        /// </returns>
        public static Course ToEntity(this AddEditCourseModel model, ProviderPortalEntities db)
        {
            Course course;

            if (model.CourseId == null)
            {
                course = new Course
                {
                    CreatedByUserId    = Permission.GetCurrentUserId(),
                    CreatedDateTimeUtc = DateTime.UtcNow
                };
            }
            else
            {
                course = db.Courses.Find(model.CourseId);
                if (course == null)
                {
                    return(null);
                }
            }

            // Get the Learning Aim if one has been specified
            LearningAim la = null;

            if (!String.IsNullOrWhiteSpace(model.LearningAimId))
            {
                la = db.LearningAims.Find(model.LearningAimId);
            }

            course.LearningAimRefId             = model.LearningAimId;
            course.WhenNoLarQualificationTypeId = la == null || la.QualificationTypeId == null ? model.QualificationTypeId : null;
            course.WhenNoLarQualificationTitle  = la == null ? model.WhenNoLarQualificationTitle : null;
            course.CourseTitle          = model.CourseTitle;
            course.ProviderOwnCourseRef = model.ProviderOwnCourseRef;
            course.CourseSummary        = model.CourseSummary;
            course.EntryRequirements    = model.EntryRequirements;
            course.QualificationLevelId = model.QualificationLevelId;
            course.Url                      = UrlHelper.GetFullUrl(model.Url);
            course.BookingUrl               = UrlHelper.GetFullUrl(model.BookingUrl);
            course.AssessmentMethod         = model.AssessmentMethod;
            course.EquipmentRequired        = model.EquipmentRequired;
            course.QualificationLevelId     = model.QualificationLevelId;
            course.AwardingOrganisationName = model.AwardingOrganisation;
            course.UcasTariffPoints         = model.UcasTariffPoints;

            return(course);
        }