Add project files.
This commit is contained in:
		
							
								
								
									
										81
									
								
								Core.Blueprint.Mongo/Entities/Document.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								Core.Blueprint.Mongo/Entities/Document.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| using Core.Blueprint.Mongo; | ||||
| using MongoDB.Bson; | ||||
| using MongoDB.Bson.Serialization.Attributes; | ||||
| using System.Text.Json.Serialization; | ||||
|  | ||||
| public class Document : IDocument | ||||
| { | ||||
|     /// <summary> | ||||
|     /// 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. | ||||
|     /// </summary> | ||||
|     [BsonId] | ||||
|     [BsonElement("_id")] | ||||
|     [BsonRepresentation(BsonType.ObjectId)] | ||||
|     [JsonPropertyName("_id")] | ||||
|     public string _Id { get; init; } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// 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. | ||||
|     /// </summary> | ||||
|     [BsonElement("id")] | ||||
|     [BsonRepresentation(BsonType.String)] | ||||
|     [JsonPropertyName("id")] | ||||
|     public string Id { get; init; } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// 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. | ||||
|     /// </summary> | ||||
|     [BsonElement("createdAt")] | ||||
|     [BsonRepresentation(BsonType.DateTime)] | ||||
|     [JsonPropertyName("createdAt")] | ||||
|     public DateTime CreatedAt { get; init; } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Gets or sets the user or system who created the document. | ||||
|     /// This field can be used for audit purposes. | ||||
|     /// </summary> | ||||
|     [BsonElement("createdBy")] | ||||
|     [BsonRepresentation(BsonType.String)] | ||||
|     [JsonPropertyName("createdBy")] | ||||
|     public string? CreatedBy { get; set; } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// 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. | ||||
|     /// </summary> | ||||
|     [BsonElement("updatedAt")] | ||||
|     [BsonRepresentation(BsonType.DateTime)] | ||||
|     [JsonPropertyName("updatedAt")] | ||||
|     public DateTime? UpdatedAt { get; set; } = null; | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Gets or sets the user or system who last updated the document. | ||||
|     /// This field can be used for audit purposes. | ||||
|     /// </summary> | ||||
|     [BsonElement("updatedBy")] | ||||
|     [BsonRepresentation(BsonType.String)] | ||||
|     [JsonPropertyName("updatedBy")] | ||||
|     public string? UpdatedBy { get; set; } = null; | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Gets or sets the status of the document.  | ||||
|     /// The status is represented by an enum and defaults to <see cref="StatusEnum.Active"/>. | ||||
|     /// </summary> | ||||
|     [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; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										28
									
								
								Core.Blueprint.Mongo/Entities/StatusEnum.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Core.Blueprint.Mongo/Entities/StatusEnum.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| using System.Text.Json.Serialization; | ||||
|  | ||||
| namespace Core.Blueprint.Mongo | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Represents the status of a document or entity. This enum is used to track the state of a document  | ||||
|     /// within the system. The `JsonStringEnumConverter` ensures that the enum values are serialized as strings  | ||||
|     /// in JSON format, rather than as numeric values. | ||||
|     /// </summary> | ||||
|     [JsonConverter(typeof(JsonStringEnumConverter))] | ||||
|     public enum StatusEnum | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Represents an active document or entity. | ||||
|         /// </summary> | ||||
|         Active = 0, | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Represents an inactive document or entity. | ||||
|         /// </summary> | ||||
|         Inactive = 1, | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Represents a deleted document or entity. | ||||
|         /// </summary> | ||||
|         Deleted = 2 | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin