using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using vendorApproverBackend.Enums; using vendorApproverBackend.Entities; namespace vendorApproverBackend.Entities; [Table("notificationmodel")] public class NotificationModel { [Key] [Column("notificatoin_id")] public long Id { get; set; } // Unidirectional relation to User (Sender) public User Sender { get; set; } [Column("SenderId")] // Explicit FK property for EF Core public long? SenderId { get; set; } // Unidirectional relation to User (Reciver) public User Reciver { get; set; } [Column("ReciverId")] // Explicit FK property for EF Core public long? ReciverId { get; set; } [Column("action")] public Action Action { get; set; } = Action.IDLE; [Column("action_id")] public long? ActionId { get; set; } [Column("subject")] public string Subject { get; set; } [Column("content")] public string Content { get; set; } [Column("logUrl")] public string LogUrl { get; set; } [Column("status")] public states Status { get; set; } = states.WAITING; [Column("timestmp")] public DateTime Timestmp { get; set; } public NotificationModel() { this.Timestmp = DateTime.UtcNow; // Use UtcNow } // Implement the toMap logic as a method returning a Dictionary public Dictionary ToMap() { return new Dictionary { { "id", this.Id.ToString() }, { "sender", this.SenderId?.ToString() ?? "" }, { "reciver", this.ReciverId?.ToString() ?? "" }, { "actionId", this.ActionId?.ToString() ?? "" }, { "status", this.Status.ToString() }, { "subject", this.Subject ?? "" }, { "content", this.Content ?? "" }, { "action", this.Action.ToString() }, { "logoUrl", this.LogUrl }, { "timestmp", this.Timestmp.ToString("") } // "o" for round-trip format }; } // Note: I've omitted the constructors that take ChatMessage as it's not defined. // The other constructors can be translated, but for brevity, only the default is shown. }