using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using e_suite.Database.Core.Tables.UserManager;
using Microsoft.EntityFrameworkCore;

namespace e_suite.Database.Core.Tables.Domain;

[DisplayName("UserAccess")]
[Table("UserAccess", Schema = "Domain")]
[Keyless]
public class UserAccess
{
    [Required]
    public long UserId { get; set; }

    [Required]
    public long DomainId { get; set; }

    /// <summary>
    /// Contains the Enum value for the security access entry
    /// </summary>
    [Required]
    public int AccessKey { get; set; }

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

    [ForeignKey(nameof(DomainId))]
    public virtual Domain Domain { get; set; } = null!;
    
    public static void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<UserAccess>()
            .HasNoKey();
    }
}