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