using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;

namespace TIAM.Entities.Emails;

[Table(nameof(EmailMessage))]
public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation
{
    public EmailMessage()
    {
    }

    public EmailMessage(Guid id, Guid? senderId, Guid contextId, string subject, string? text, string senderEmailAddress) : this()
    {
        Id = id;
        SenderId = senderId;
        ContextId = contextId;
        Subject = subject;
        Text = text;
        SenderEmailAddress = senderEmailAddress;
    }

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

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

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

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

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