From 05145ea7cb8fefe8d64161f2696c128c2e522342 Mon Sep 17 00:00:00 2001 From: Slendy Date: Tue, 14 May 2024 16:00:42 -0500 Subject: [PATCH] Set published at for announcements and set default value --- .../Pages/NotificationsPage.cshtml | 4 +++- .../Pages/NotificationsPage.cshtml.cs | 1 + .../20240514032620_AddPublishedAtToWebAnnouncement.cs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml index a6eaa43d..7bede06c 100644 --- a/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml @@ -2,13 +2,14 @@ @using LBPUnion.ProjectLighthouse.Localization.StringLists @using LBPUnion.ProjectLighthouse.Types.Entities.Notifications @using LBPUnion.ProjectLighthouse.Types.Entities.Website -@using LBPUnion.ProjectLighthouse.Types.Notifications @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.NotificationsPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "Layouts/BaseLayout"; Model.Title = Model.Translate(GeneralStrings.Notifications); + string timeZone = Model.GetTimeZone(); + TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone); } @if (Model.User != null && Model.User.IsAdmin) @@ -51,6 +52,7 @@ @announcement.Publisher.Username + at @TimeZoneInfo.ConvertTime(announcement.PublishedAt, TimeZoneInfo.Utc, timeZoneInfo).ToString("M/d/yyyy h:mm:ss tt") } diff --git a/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml.cs index 8595ee85..0849304b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/NotificationsPage.cshtml.cs @@ -54,6 +54,7 @@ public class NotificationsPage : BaseLayout Title = title.Trim(), Content = content.Trim(), PublisherId = user.UserId, + PublishedAt = DateTime.UtcNow, }; this.Database.WebsiteAnnouncements.Add(announcement); diff --git a/ProjectLighthouse/Migrations/20240514032620_AddPublishedAtToWebAnnouncement.cs b/ProjectLighthouse/Migrations/20240514032620_AddPublishedAtToWebAnnouncement.cs index 66d5d8e7..88b54e9f 100644 --- a/ProjectLighthouse/Migrations/20240514032620_AddPublishedAtToWebAnnouncement.cs +++ b/ProjectLighthouse/Migrations/20240514032620_AddPublishedAtToWebAnnouncement.cs @@ -19,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Migrations table: "WebsiteAnnouncements", type: "datetime(6)", nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + defaultValue: DateTime.UtcNow); } ///