using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net.Mail;
using AyCode.Core.Enums;
using AyCode.Interfaces.Messages;

namespace AyCode.Entities.Messages;

[Table("EmailMessage")]
public abstract class AcEmailMessage<TEmailRecipient> : IAcEmailMessage<TEmailRecipient> where TEmailRecipient : IAcEmailRecipientBase
{
    protected AcEmailMessage()
    {
    }

    protected AcEmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string emailAddress) : this()
    {
        Id = id;
        SenderId = senderId;
        ContextId = contextId;
        Subject = subject;
        Text = text;
        EmailAddress = emailAddress;
    }

    [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
    public Guid Id { get; set; }

    public Guid ContextId { get; set; }
    public Guid? SenderId { get; set; }
    public MessageContextType ContextType { get; set; }

    public virtual List<TEmailRecipient> Recipients { get; set; } = [];

    [MaxLength(150)]
    public string EmailAddress { get; set; }
    [MaxLength(100)]
    public string Subject { get; set; }
    public string? Text { get; set; }

    public bool IsReaded { get; set; }

    public DateTime Created { get; set; }
    public DateTime Modified { get; set; }
}