2023-11-14 04:56:06 +00:00
|
|
|
using BotSharp.Abstraction.Users.Enums;
|
2023-11-14 14:13:54 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2023-08-19 00:15:02 +00:00
|
|
|
|
|
|
|
|
namespace BotSharp.OpenAPI.ViewModels.Users;
|
|
|
|
|
|
|
|
|
|
public class UserViewModel
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
2024-01-05 03:20:50 +00:00
|
|
|
[JsonPropertyName("user_name")]
|
|
|
|
|
public string UserName { get; set; }
|
2023-11-14 14:13:54 +00:00
|
|
|
[JsonPropertyName("first_name")]
|
2023-08-19 00:15:02 +00:00
|
|
|
public string FirstName { get; set; }
|
2023-11-14 14:13:54 +00:00
|
|
|
[JsonPropertyName("last_name")]
|
2023-08-19 00:15:02 +00:00
|
|
|
public string LastName { get; set; }
|
|
|
|
|
public string Email { get; set; }
|
2023-11-14 04:56:06 +00:00
|
|
|
public string Role { get; set; } = UserRole.Client;
|
2023-11-14 14:13:54 +00:00
|
|
|
[JsonPropertyName("full_name")]
|
2023-11-14 01:25:25 +00:00
|
|
|
public string FullName => $"{FirstName} {LastName}";
|
2024-01-23 19:32:35 +00:00
|
|
|
[JsonPropertyName("external_id")]
|
|
|
|
|
public string? ExternalId { get; set; }
|
|
|
|
|
[JsonPropertyName("create_date")]
|
|
|
|
|
public DateTime CreateDate { get; set; }
|
|
|
|
|
[JsonPropertyName("update_date")]
|
|
|
|
|
public DateTime UpdateDate { get; set; }
|
2023-11-14 01:25:25 +00:00
|
|
|
|
2023-08-19 00:15:02 +00:00
|
|
|
public static UserViewModel FromUser(User user)
|
|
|
|
|
{
|
2023-11-15 13:33:46 +00:00
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
return new UserViewModel
|
|
|
|
|
{
|
|
|
|
|
FirstName = "AI",
|
|
|
|
|
LastName = "Assistant",
|
|
|
|
|
Role = AgentRole.Assistant
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-19 00:15:02 +00:00
|
|
|
return new UserViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = user.Id,
|
2024-01-05 03:20:50 +00:00
|
|
|
UserName = user.UserName,
|
2023-08-19 00:15:02 +00:00
|
|
|
FirstName = user.FirstName,
|
|
|
|
|
LastName = user.LastName,
|
2023-11-14 04:56:06 +00:00
|
|
|
Email = user.Email,
|
2024-01-23 19:32:35 +00:00
|
|
|
Role = user.Role,
|
|
|
|
|
ExternalId = user.ExternalId,
|
|
|
|
|
CreateDate = user.CreatedTime,
|
|
|
|
|
UpdateDate = user.UpdatedTime
|
2023-08-19 00:15:02 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|