diff --git a/PC2/Controllers/AboutController.cs b/PC2/Controllers/AboutController.cs index b7761fd..b255a2e 100644 --- a/PC2/Controllers/AboutController.cs +++ b/PC2/Controllers/AboutController.cs @@ -1,11 +1,8 @@ -using Humanizer; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.DotNet.Scaffolding.Shared.Project; using Microsoft.EntityFrameworkCore; using PC2.Data; using PC2.Models; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace PC2.Controllers { diff --git a/PC2/Controllers/EventsController.cs b/PC2/Controllers/EventsController.cs index feac0c7..1f78d9f 100644 --- a/PC2/Controllers/EventsController.cs +++ b/PC2/Controllers/EventsController.cs @@ -18,11 +18,37 @@ public async Task Index(string? eventType) bool getPc2Events = eventType == null; EventsModel eventsModel = new() { - IsPC2EventCalendar = getPc2Events, + IsPC2EventCalendar = getPc2Events, CalendarEvents = await CalendarEventDB.GetAllEvents(_context, getPc2Events) }; return View(eventsModel); } + + // Returns events in JSON format for FullCalendar + public async Task GetEvents(string? eventType) + { + bool getPc2Events = string.IsNullOrEmpty(eventType) || eventType == "PC2"; + + // Get events from the database + List events = await CalendarEventDB.GetAllEvents(_context, getPc2Events); + + // Create a list to hold FullCalendar-compatible events + List fullCalendarEvents = new List(); + + // Loop through the events and add them to the list + foreach (var e in events) + { + var calendarEvent = new + { + title = e.EventDescription, + start = e.StartingDateTime.ToString("yyyy-MM-ddTHH:mm:ss"), // FullCalendar format + end = e.EndingDateTime.ToString("yyyy-MM-ddTHH:mm:ss"), // FullCalendar format + }; + fullCalendarEvents.Add(calendarEvent); + } + + return Json(fullCalendarEvents); + } } } diff --git a/PC2/Models/CalendarEvent.cs b/PC2/Models/CalendarEvent.cs index 2cf9178..c3df760 100644 --- a/PC2/Models/CalendarEvent.cs +++ b/PC2/Models/CalendarEvent.cs @@ -40,6 +40,23 @@ public class CalendarEvent : IComparable /// public bool CountyEvent { get; set; } + // Convert DateOnly and TimeOnly to DateTime + public DateTime StartingDateTime + { + get + { + return DateOfEvent.ToDateTime(StartingTime); + } + } + + public DateTime EndingDateTime + { + get + { + return DateOfEvent.ToDateTime(EndingTime); + } + } + public int CompareTo(CalendarEvent? other) { return this.DateOfEvent.CompareTo(other.DateOfEvent); diff --git a/PC2/Views/Events/Index.cshtml b/PC2/Views/Events/Index.cshtml index 042b43c..855da67 100644 --- a/PC2/Views/Events/Index.cshtml +++ b/PC2/Views/Events/Index.cshtml @@ -1,5 +1,17 @@ @model PC2.Models.EventsModel + @{ + // Allows calendar to switch between PC2 and County events by grabbing the eventType + var eventType = Context.Request.Query["eventType"].ToString(); + if (string.IsNullOrEmpty(eventType) || eventType == "PC2") + { + Model.IsPC2EventCalendar = true; + } + else + { + Model.IsPC2EventCalendar = false; + } + if (Model.IsPC2EventCalendar) { ViewData["Title"] = "PC2 Events and Activities"; @@ -8,12 +20,6 @@ { ViewData["Title"] = "County-wide Events and Activities"; } - - List> eventDateGroups = - Model.CalendarEvents - .GroupBy(calEvent => calEvent.DateOfEvent) - .Select(group => group.ToList()) - .ToList(); }
@@ -22,46 +28,22 @@
+

@ViewData["Title"]

-
-
- -@section Head{ +@section Head { } + @if (Model.IsPC2EventCalendar) {

@@ -71,79 +53,91 @@ else {

- View PC2 Events + View PC2 Events

} +
-@if (Model.CalendarEvents.Count > 0) -{ -
-
- - - - - - - - - - @for (int currentDate = 0; currentDate < eventDateGroups.Count; currentDate++) - { - - - @*loop through all events on this date*@ - @for (int currentEvent = 0; currentEvent < eventDateGroups[currentDate].Count; currentEvent++) - { - string eventDescription = eventDateGroups[currentDate][currentEvent].EventDescription; - @if (currentEvent > 0) // if this is not the first event on this date, then start a new row - { - - - - - } - else - { - - - } - } - - } - -
DateTimeEvent
-
@eventDateGroups[currentDate][0].DateOfEvent.Day
-
@eventDateGroups[currentDate][0].DateOfEvent.DayOfWeek
-
@eventDateGroups[currentDate][0].DateOfEvent.ToString("MMMM"), @eventDateGroups[currentDate][0].DateOfEvent.Year
-
- @eventDateGroups[currentDate][currentEvent].StartingTime  -  @eventDateGroups[currentDate][currentEvent].EndingTime - -
- @*// use partial view, pass in eventdescription as ViewData*@ - @(await Html.PartialAsync("~/Views/Calendar/_IndexPartial.cshtml", new ViewDataDictionary(ViewData) { { "eventDescription", eventDescription } })) -
-
- @eventDateGroups[currentDate][currentEvent].StartingTime  -  @eventDateGroups[currentDate][currentEvent].EndingTime - -
- @*// use partial view, pass in eventdescription as ViewData*@ - @(await Html.PartialAsync("~/Views/Calendar/_IndexPartial.cshtml", new ViewDataDictionary(ViewData) { { "eventDescription", eventDescription } })) -
-
+ + + + + + + +
@if (Model.IsPC2EventCalendar) { PC2 Activities and Social Gatherings - Events Flyer

Downloadable 2024 Activities Flyer

-} \ No newline at end of file +} diff --git a/PC2/wwwroot/css/site.css b/PC2/wwwroot/css/site.css index 2b9db90..cb9c7f6 100644 --- a/PC2/wwwroot/css/site.css +++ b/PC2/wwwroot/css/site.css @@ -591,3 +591,41 @@ div.results:hover, div.results:hover #agencyName2 { max-height : 550px; overflow-y: auto; } + +/* Event Calendar CSS*/ + +/* Calendar styles for small screen sizes */ +@media (max-width: 768px) { + #calendar { + font-size: 13px; + } + + .fc-header-toolbar { + flex-direction: column; + align-items: center; + } + + .fc-button { + padding: 5px 10px; + font-size: 12px; + } +} + +/* Modal styles for small screen sizes */ +@media (max-width: 767px) { + .modal-dialog { + max-width: 75%; + } +} + +/* Make current day more obvious */ +.fc-day-today { + font-weight: bold; +} + +.fc-event { + background-color: cornflowerblue !important; +} + + +