LANCommander/LANCommander.Server.Data/Models/Role.cs

40 lines
1.1 KiB
C#
Raw Permalink Normal View History

using Microsoft.AspNetCore.Identity;
2024-10-15 23:48:16 -05:00
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2024-08-04 18:44:33 -05:00
namespace LANCommander.Server.Data.Models
{
[Table("Roles")]
2024-10-15 23:48:16 -05:00
public class Role : IdentityRole<Guid>, IBaseModel
{
2024-11-27 01:51:47 -06:00
public ICollection<Collection> Collections { get; set; }
public ICollection<UserRole> UserRoles { get; set; }
2024-10-16 16:29:55 -05:00
[NotMapped]
public ICollection<User> Users
{
get
{
return UserRoles?.Select(ur => ur.User).ToArray() ?? [];
}
}
2024-10-15 23:48:16 -05:00
[Display(Name = "Created On")]
public DateTime CreatedOn { get; set; } = DateTime.UtcNow;
2024-10-15 23:48:16 -05:00
public Guid? CreatedById { get; set; }
[ForeignKey(nameof(CreatedById))]
2024-10-15 23:48:16 -05:00
[Display(Name = "Created By")]
2024-11-27 01:51:47 -06:00
public User? CreatedBy { get; set; }
2024-10-15 23:48:16 -05:00
[Display(Name = "Updated On")]
public DateTime UpdatedOn { get; set; } = DateTime.UtcNow;
2024-10-15 23:48:16 -05:00
public Guid? UpdatedById { get; set; }
[ForeignKey(nameof(UpdatedById))]
2024-10-15 23:48:16 -05:00
[Display(Name = "Updated By")]
2024-11-27 01:51:47 -06:00
public User? UpdatedBy { get; set; }
}
}