using e_suite.Database.Core.Tables.Contacts;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using e_suite.Database.Audit.Attributes;

namespace e_suite.Database.Core.Tables.Printer
{
    [DisplayName("Site Contact")]
    [Table("SiteContacts", Schema = "Printer")]
    public class SiteContact
    {
        public long SiteId { get; set; }

        public long ContactId { get; set; }

        [Required]
        public bool Primary { get; set; }

        [AuditLastUpdated]
        public DateTimeOffset LastUpdated { get; set; }

        [AuditParent]
        [ForeignKey(nameof(SiteId))]
        public virtual Site Site { get; set; } = null!;

        [AuditParent]
        [ForeignKey(nameof(ContactId))]
        public virtual Contact Contact { get; set; } = null!;

        public static void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SiteContact>()
                .HasKey(nameof(SiteId), nameof(ContactId));
        }
    }
}
