using Core.Blueprint.Mongo; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; using System.Text.Json.Serialization; public class Document : IDocument { /// /// Gets or sets the MongoDB ObjectId for the document. /// This property is automatically generated if not provided. /// It is used as the primary key for the document in MongoDB. /// [BsonId] [BsonElement("_id")] [BsonRepresentation(BsonType.ObjectId)] [JsonPropertyName("_id")] public string _Id { get; init; } /// /// Gets or sets a unique identifier for the document, represented as a string (GUID). /// This value is automatically generated if not provided and can be used as a secondary key. /// [BsonElement("id")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("id")] public string Id { get; init; } /// /// Gets or sets the timestamp of when the document was created. /// This value is automatically set to the current UTC time when the document is created. /// [BsonElement("createdAt")] [BsonRepresentation(BsonType.DateTime)] [JsonPropertyName("createdAt")] public DateTime CreatedAt { get; init; } /// /// Gets or sets the user or system who created the document. /// This field can be used for audit purposes. /// [BsonElement("createdBy")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("createdBy")] public string? CreatedBy { get; set; } /// /// Gets or sets the timestamp of when the document was last updated. /// This value is nullable and will be set to null if the document has never been updated. /// [BsonElement("updatedAt")] [BsonRepresentation(BsonType.DateTime)] [JsonPropertyName("updatedAt")] public DateTime? UpdatedAt { get; set; } = null; /// /// Gets or sets the user or system who last updated the document. /// This field can be used for audit purposes. /// [BsonElement("updatedBy")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("updatedBy")] public string? UpdatedBy { get; set; } = null; /// /// Gets or sets the status of the document. /// The status is represented by an enum and defaults to . /// [BsonElement("status")] [BsonRepresentation(BsonType.String)] [JsonPropertyName("status")] [JsonConverter(typeof(JsonStringEnumConverter))] public StatusEnum? Status { get; set; } public Document() { _Id = ObjectId.GenerateNewId().ToString(); Id = Guid.NewGuid().ToString(); CreatedAt = DateTime.UtcNow; Status = StatusEnum.Active; } }