public static List <String> GetWarningMessages(this AddEditOpportunityModel model) { List <String> messages = new List <String>(); if (!String.IsNullOrWhiteSpace(model.Url) && !UrlHelper.UrlIsReachable(model.Url)) { messages.Add(String.Format(AppGlobal.Language.GetText("AddEditOpportunityModel_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("AddEditOpportunityModel_DisplayName_Url", "URL"))); } return(messages); }
/// <summary> /// Convert an <see cref="AddEditOpportunityModel"/> to an <see cref="CourseInstance"/>. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="db"> /// The db. /// </param> /// <returns> /// The <see cref="CourseInstance"/>. /// </returns> public static CourseInstance ToEntity(this AddEditOpportunityModel model, ProviderPortalEntities db) { CourseInstance courseInstance; if (model.OpportunityId == null) { courseInstance = new CourseInstance { CourseId = model.CourseId, CreatedByUserId = Permission.GetCurrentUserId(), CreatedDateTimeUtc = DateTime.UtcNow }; } else { courseInstance = db.CourseInstances.Find(model.OpportunityId); if (courseInstance == null) { return(null); } } courseInstance.DisplayedByOrganisationId = model.DisplayId; courseInstance.OfferedByOrganisationId = model.OfferedById; courseInstance.BothOfferedByDisplayBySearched = model.DisplayId != model.OfferedById && model.BothOfferedByDisplayBySearched; courseInstance.ProviderOwnCourseInstanceRef = model.ProviderOwnOpportunityRef; courseInstance.StudyModeId = model.StudyModeId; courseInstance.AttendanceTypeId = model.AttendanceModeId; courseInstance.AttendancePatternId = model.AttendancePatternId; courseInstance.DurationUnit = model.Duration; courseInstance.DurationUnitId = model.DurationUnitId; courseInstance.DurationAsText = model.DurationDescription; courseInstance.StartDateDescription = model.StartDateDescription; courseInstance.EndDate = model.EndDate; courseInstance.TimeTable = model.Timetable; courseInstance.Price = model.Price; courseInstance.PriceAsText = model.PriceDescription; courseInstance.LanguageOfInstruction = model.LanguageOfInstruction; courseInstance.LanguageOfAssessment = model.LanguageOfAssessment; courseInstance.ApplyFromDate = model.ApplyFrom; courseInstance.ApplyUntilDate = model.ApplyUntil; courseInstance.ApplyUntilText = model.ApplyUntilDescription; courseInstance.EnquiryTo = model.EnquireTo; courseInstance.ApplyTo = model.ApplyTo; courseInstance.Url = UrlHelper.GetFullUrl(model.Url); courseInstance.CanApplyAllYear = model.AcceptedThroughoutYear; courseInstance.VenueLocationId = model.RegionId; return(courseInstance); }