108 lines
3.5 KiB
C#
108 lines
3.5 KiB
C#
// ***********************************************************************
|
|
// <copyright file="RoleAdapter.cs">
|
|
// Heath
|
|
// </copyright>
|
|
// ***********************************************************************
|
|
|
|
using Core.Cerberos.Adapters.Common.Enums;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Core.Cerberos.Adapters
|
|
{
|
|
/// <summary>
|
|
/// Adapter representing a role.
|
|
/// </summary>
|
|
public class RoleAdapter
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the unique identifier of the role.
|
|
/// </summary>
|
|
[BsonId]
|
|
[BsonElement("_id")]
|
|
[BsonRepresentation(BsonType.ObjectId)]
|
|
[JsonPropertyName("id")]
|
|
public string Id { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the name of the role.
|
|
/// </summary>
|
|
[BsonElement("name")]
|
|
[BsonRepresentation(BsonType.String)]
|
|
[JsonPropertyName("name")]
|
|
public string Name { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the description of the role.
|
|
/// </summary>
|
|
[BsonElement("description")]
|
|
[BsonRepresentation(BsonType.String)]
|
|
[JsonPropertyName("description")]
|
|
public string? Description { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of the entity.
|
|
/// </summary>
|
|
[BsonElement("applications")]
|
|
[JsonPropertyName("applications")]
|
|
[JsonConverter(typeof(EnumArrayJsonConverter<ApplicationsEnum>))]
|
|
public ApplicationsEnum[]? Applications { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the modules of the role.
|
|
/// </summary>
|
|
[BsonElement("modules")]
|
|
[JsonPropertyName("modules")]
|
|
public string[] Modules { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the permissions of the role.
|
|
/// </summary>
|
|
[BsonElement("permissions")]
|
|
[JsonPropertyName("permissions")]
|
|
public string[] Permissions { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the date and time when the entity was created.
|
|
/// </summary>
|
|
[BsonElement("createdAt")]
|
|
[BsonRepresentation(BsonType.DateTime)]
|
|
[JsonPropertyName("createdAt")]
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the user who created the entity.
|
|
/// </summary>
|
|
[BsonElement("createdBy")]
|
|
[BsonRepresentation(BsonType.String)]
|
|
[JsonPropertyName("createdBy")]
|
|
public string? CreatedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the date and time when the entity was last updated.
|
|
/// </summary>
|
|
[BsonElement("updatedAt")]
|
|
[BsonRepresentation(BsonType.DateTime)]
|
|
[JsonPropertyName("updatedAt")]
|
|
public DateTime? UpdatedAt { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the user who last updated the entity.
|
|
/// </summary>
|
|
[BsonElement("updatedBy")]
|
|
[BsonRepresentation(BsonType.String)]
|
|
[JsonPropertyName("updatedBy")]
|
|
public string? UpdatedBy { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of the entity.
|
|
/// </summary>
|
|
[BsonElement("status")]
|
|
[BsonRepresentation(BsonType.String)]
|
|
[JsonPropertyName("status")]
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
public StatusEnum Status { get; set; } = StatusEnum.Active;
|
|
}
|
|
}
|