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

namespace e_suite.Database.Core.Tables.Sentinel;

[NoAudit]
[Table("FailedAccessAttempts", Schema = "Sentinel")]
public class FailedAccessAttempt
{
    [Required, MaxLength(50)]
    // ReSharper disable once InconsistentNaming
    public string IPAddress { get; set; } = string.Empty;

    [Required]
    public DateTimeOffset AttemptedTime { get; set; }

    public static void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<FailedAccessAttempt>().HasKey(p => new { p.IPAddress, p.AttemptedTime });
    }
}