diff --git a/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Controllers/AddEventController.cs b/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Controllers/AddEventController.cs index f7e95f5..ce8ea24 100644 --- a/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Controllers/AddEventController.cs +++ b/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Controllers/AddEventController.cs @@ -96,6 +96,20 @@ public async Task IndexAsync(AddEventViewModel model) } } + + // Check if model.Url is a valid URL + if (!string.IsNullOrWhiteSpace(model.Url)) + { + if (!model.Url.StartsWith("http://") && !model.Url.StartsWith("https://")) + { + model.Url = "https://" + model.Url; + } + if (!Uri.IsWellFormedUriString(model.Url, UriKind.Absolute)) + { + ModelState.AddModelError("Url", "Invalid URL"); + } + } + if (!ModelState.IsValid) return View(model); diff --git a/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Views/Admin/Index.cshtml b/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Views/Admin/Index.cshtml index ef9e858..54f17a4 100644 --- a/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Views/Admin/Index.cshtml +++ b/src/TechCommunityCalendar.Solution/TechCommunityCalendar.CoreWebApplication/Views/Admin/Index.cshtml @@ -1,12 +1,20 @@ @using System.Web; +@using System.Text.Unicode @model AdminEventsViewModel +@functions { + public static string EncodeUrl(string value) + { + return HttpUtility.UrlEncode(value); + } +} +

Hidden

@foreach (var techEvent in Model.TechEvents.Where(x => x.Hidden)) { - + @@ -22,7 +30,7 @@ @foreach (var techEvent in Model.TechEvents.Where(x => !x.Hidden)) { - +
@techEvent.Name@techEvent.Name @techEvent.EventType @techEvent.Duration @techEvent.StartDate.ToShortDateString()
@techEvent.Name@techEvent.Name @techEvent.EventType @techEvent.Duration @techEvent.StartDate.ToShortDateString()