Skip to content

Commit

Permalink
Set published at for announcements and set default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Slendy committed May 14, 2024
1 parent 94fe2d4 commit 05145ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task<IActionResult> OnPost([FromForm] string title, [FromForm] stri
Title = title.Trim(),
Content = content.Trim(),
PublisherId = user.UserId,
PublishedAt = DateTime.UtcNow,
};

this.Database.WebsiteAnnouncements.Add(announcement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "WebsiteAnnouncements",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
defaultValue: DateTime.UtcNow);
}

/// <inheritdoc />
Expand Down

0 comments on commit 05145ea

Please sign in to comment.