using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace watcher_monitoring.Models;

public class User
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [Required]
    [StringLength(50)]
    public required string Username { get; set; } = null!;

    [Required]
    [EmailAddress]
    public required string Email { get; set; }

    public DateTime LastLogin { get; set; } = DateTime.UtcNow;

    [Required]
    [DataType(DataType.Password)]
    public required string Password { get; set; }

    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    public bool IsActive { get; set; } = true;

    [StringLength(255)]
    public string? OidcSubject { get; set; }

    public bool IsOidcUser => !string.IsNullOrEmpty(OidcSubject);

    // Navigation Property: Ein User kann mehrere API-Keys haben
    public ICollection<ApiKey> ApiKeys { get; set; } = new List<ApiKey>();
}
