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

namespace e_suite.Database.Core.Tables.Printer
{
    [DisplayName("Organisation Contact")]
    [Table("OrganisationContacts", Schema = "Printer")]
    public class OrganisationContact
    {
        public long OrganisationId { get; set; }

        public long ContactId { get; set; }

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

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

        [ForeignKey(nameof(OrganisationId))]
        public virtual Organisation Organisation { get; set; } = null!;

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

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