From 39a840fd2dbd4c3c0a2a20142c1abc8c6afb4e9f Mon Sep 17 00:00:00 2001 From: Danil Iarosh Date: Tue, 13 Jan 2026 11:08:15 +0300 Subject: [PATCH] Update Profile page to use ViewModel and display full user info including skills --- CORP-MAUI/Models/User.cs | 34 ++++ CORP-MAUI/Pages/ProfilePage.xaml | 66 ++++--- CORP-MAUI/Pages/ProfilePage.xaml.cs | 85 +-------- CORP-MAUI/ViewModels/ProfileViewModel.cs | 218 +++++++++++++++++++++++ 4 files changed, 303 insertions(+), 100 deletions(-) create mode 100644 CORP-MAUI/ViewModels/ProfileViewModel.cs diff --git a/CORP-MAUI/Models/User.cs b/CORP-MAUI/Models/User.cs index dea0bf5..0ec0bb9 100644 --- a/CORP-MAUI/Models/User.cs +++ b/CORP-MAUI/Models/User.cs @@ -1,3 +1,4 @@ +using System.Text.Json; using System.Text.Json.Serialization; namespace CORP_MAUI.Models; @@ -32,6 +33,25 @@ public class User [JsonIgnore] public string FullName => $"{FirstName} {LastName}".Trim(); + [JsonIgnore] + public string? DisplayAvatarUrl + { + get + { + if (string.IsNullOrEmpty(AvatarUrl)) return null; + + // Handle protocol-relative URLs + if (AvatarUrl.StartsWith("//")) + return $"https:{AvatarUrl}"; + + if (AvatarUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + return AvatarUrl; + + string cleanUrl = AvatarUrl.TrimStart('/'); + return $"https://corp.robotail.pro/{cleanUrl}"; + } + } + [JsonIgnore] public string DepartmentName { @@ -41,6 +61,13 @@ public class User return dept.Name; if (Department is string str) return str; + if (Department is JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + return element.GetString() ?? string.Empty; + if (element.ValueKind == JsonValueKind.Object && element.TryGetProperty("name", out JsonElement nameProp)) + return nameProp.GetString() ?? string.Empty; + } return string.Empty; } } @@ -54,6 +81,13 @@ public class User return pos.Name; if (Position is string str) return str; + if (Position is JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + return element.GetString() ?? string.Empty; + if (element.ValueKind == JsonValueKind.Object && element.TryGetProperty("name", out JsonElement nameProp)) + return nameProp.GetString() ?? string.Empty; + } return string.Empty; } } diff --git a/CORP-MAUI/Pages/ProfilePage.xaml b/CORP-MAUI/Pages/ProfilePage.xaml index a739499..9f83564 100644 --- a/CORP-MAUI/Pages/ProfilePage.xaml +++ b/CORP-MAUI/Pages/ProfilePage.xaml @@ -6,6 +6,11 @@ + + + + + + + + + + Command="{Binding LoadProfileCommand}"/>