diff --git a/TASVideos/Pages/Logs/Index.cshtml b/TASVideos/Pages/Logs/Index.cshtml index e790fc6a7..6a1dfe7d2 100644 --- a/TASVideos/Pages/Logs/Index.cshtml +++ b/TASVideos/Pages/Logs/Index.cshtml @@ -12,7 +12,7 @@ @entry.RowId - @entry.UserId + @entry.UserName diff --git a/TASVideos/Pages/Logs/Index.cshtml.cs b/TASVideos/Pages/Logs/Index.cshtml.cs index 5f6b5fd26..0960db5d5 100644 --- a/TASVideos/Pages/Logs/Index.cshtml.cs +++ b/TASVideos/Pages/Logs/Index.cshtml.cs @@ -30,14 +30,15 @@ public IndexModel(ApplicationDbContext db) public async Task OnGet() { var query = _db.AutoHistory - .Select(h => new LogEntry + .GroupJoin(_db.Users, outerKey => outerKey.UserId, innerKey => innerKey.Id, (h, user) => new { h, user }) + .SelectMany(g => g.user.DefaultIfEmpty(), (g, user) => new LogEntry { - RowId = h.RowId, - UserId = h.UserId, - Created = h.Created, - TableName = h.TableName, - Changed = h.Changed, - Kind = h.Kind, + RowId = g.h.RowId, + UserName = user == null ? "Unknown_User" : user.UserName, + Created = g.h.Created, + TableName = g.h.TableName, + Changed = g.h.Changed, + Kind = g.h.Kind, }); if (!string.IsNullOrWhiteSpace(Table)) @@ -70,7 +71,7 @@ public class LogEntry public string RowId { get; init; } = ""; [Sortable] - public int UserId { get; init; } + public string UserName { get; init; } [Sortable] public DateTime Created { get; init; } = DateTime.UtcNow;