36 lines
831 B
C#
36 lines
831 B
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace watcher_monitoring.Models;
|
|
|
|
public class ApiKey
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(64)]
|
|
public string Key { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string? Description { get; set; }
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
public DateTime? ExpiresAt { get; set; }
|
|
|
|
public DateTime? LastUsedAt { get; set; }
|
|
|
|
public bool IsActive { get; set; } = true;
|
|
|
|
public bool IsExpired => ExpiresAt.HasValue && ExpiresAt.Value < DateTime.UtcNow;
|
|
|
|
// Foreign Key: Jeder API-Key gehört zu einem User
|
|
public int UserId { get; set; }
|
|
|
|
// Navigation Property
|
|
public User User { get; set; } = null!;
|
|
}
|