BotSharp/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Users/UserViewModel.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2023-11-15 13:33:46 +00:00
using BotSharp.Abstraction.Agents.Enums;
2023-11-14 04:56:06 +00:00
using BotSharp.Abstraction.Users.Enums;
2023-08-19 00:15:02 +00:00
using BotSharp.Abstraction.Users.Models;
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; }
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}";
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,
FirstName = user.FirstName,
LastName = user.LastName,
2023-11-14 04:56:06 +00:00
Email = user.Email,
Role = user.Role
2023-08-19 00:15:02 +00:00
};
}
}