Set published at for announcements and set default value

This commit is contained in:
Slendy 2024-05-14 16:00:42 -05:00
commit 05145ea7cb
No known key found for this signature in database
GPG key ID: 7288D68361B91428
3 changed files with 5 additions and 2 deletions

View file

@ -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 @@
<a style="color: black" href="~/user/@announcement.Publisher.UserId">
@announcement.Publisher.Username
</a>
at @TimeZoneInfo.ConvertTime(announcement.PublishedAt, TimeZoneInfo.Utc, timeZoneInfo).ToString("M/d/yyyy h:mm:ss tt")
</div>
}
</div>

View file

@ -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);

View file

@ -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);
}
/// <inheritdoc />