diff --git a/.vscode/launch.json b/.vscode/launch.json index 8af787f..1955653 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/net7.0/vassago.dll", + "program": "${workspaceFolder}/bin/Debug/net8.0/vassago.dll", "args": [], "cwd": "${workspaceFolder}", "stopAtEntry": false, diff --git a/Models/User.cs b/Models/User.cs index bd0ed03..f4abb9b 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -18,11 +18,18 @@ public class User { get { - return Accounts.Select(a => a.DisplayName).Distinct() - .MaxBy(distinctName => - Accounts.Select(a => a.DisplayName) - .Where(selectedName => selectedName == distinctName).Count() - ); + if (Accounts?.Any() ?? false) + { + return Accounts.Select(a => a.DisplayName).Distinct() + .MaxBy(distinctName => + Accounts.Select(a => a.DisplayName) + .Where(selectedName => selectedName == distinctName).Count() + ); + } + else + { + return $"[accountless {Id}"; + } } } } \ No newline at end of file diff --git a/WebInterface/Controllers/HomeController.cs b/WebInterface/Controllers/HomeController.cs index 6bda4cb..b790795 100644 --- a/WebInterface/Controllers/HomeController.cs +++ b/WebInterface/Controllers/HomeController.cs @@ -166,11 +166,10 @@ public class HomeController : Controller } private void serializeUser(ref StringBuilder sb, ref List allAccounts, User currentUser) { - sb.Append($"{{\"text\": " + - $"\"" - + currentUser.DisplayName + - "\", "); -// \"{currentUser.DisplayName}\", "); + Console.WriteLine(currentUser); + sb.Append($"{{\"text\": \""); + sb.Append(currentUser.DisplayName); + sb.Append("\", "); var ownedAccounts = allAccounts.Where(a => a.IsUser == currentUser); sb.Append("nodes: ["); sb.Append($"{{\"text\": \"owned accounts:\", \"expanded\":true, \"nodes\": [");