using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Domain.Entities.Members; using Domain.Entities.Notifications.ValueObject; namespace Domain.Entities.Notifications; public class Notification { [ForeignKey(nameof(MemberID))] public virtual Member? Member { get; private set; } [Key] public int ID { get; private set; } public int MemberID { get; private set; } public NotificationType Type { get; private set; } public string Title { get; private set; } = default!; public string Message { get; private set; } = default!; public bool IsRead { get; private set; } public string? ActionUrl { get; private set; } public string? RelatedType { get; private set; } public int? RelatedID { get; private set; } public string? ImageUrl { get; private set; } public DateTime? ReadAt { get; private set; } public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; private Notification() { } public static Notification Create( int memberID, NotificationType type, string title, string message, string? actionUrl = null, string? relatedType = null, int? relatedID = null, string? imageUrl = null ) { return new Notification { MemberID = memberID, Type = type, Title = title, Message = message, ActionUrl = actionUrl, RelatedType = relatedType, RelatedID = relatedID, ImageUrl = imageUrl }; } public void MarkRead() { if (!IsRead) { IsRead = true; ReadAt = DateTime.UtcNow; } } }