[DB] DbContext relations

This commit is contained in:
max
2025-02-02 23:33:00 +01:00
parent 0f6b2fec88
commit 2938e1311f
10 changed files with 71 additions and 22 deletions

View File

@@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Models\Data\" />
<Folder Include="Models\Security\" />
</ItemGroup>

View File

@@ -1,26 +1,18 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityAttribute
public class AuthorityAttribute(string attributeKey, Guid bound)
{
public AuthorityAttribute(string attributeKey, string bound)
public AuthorityAttribute() : this(string.Empty, Guid.NewGuid())
{
AttributeKey = attributeKey;
BoundId = bound;
}
public AuthorityAttribute()
{
AttributeKey = string.Empty;
BoundId = string.Empty;
}
public string AttributeKey { get; set; } // ClaimType/Authority.attribute.enabled
public Guid BoundId { get; set; } = bound;
public string BoundId { get; set; } // Bound to User, Group, Role id
public string AttributeKey { get; set; } = attributeKey;
public object? AttributeValue { get; set; }
public string AttributeValue { get; set; } = string.Empty;
public string? Type { get; set; } // AspNet.Claim.Role/Property/Data.JSON, Data.Raw, Data.Base64 etc.
public string? Type { get; set; }
public long Version { get; set; }
}

View File

@@ -20,4 +20,5 @@ public class AuthorityGroup
public long Version { get; set; }
public DateTime CreatedDate { get; set; }
public ICollection<AuthorityAttribute> Attributes { get; set; } = [];
}

View File

@@ -1,6 +1,6 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public abstract class AuthorityRole()
public class AuthorityRole()
{
public AuthorityRole(string name) : this()
{

View File

@@ -41,5 +41,7 @@ public class AuthorityUser()
public bool PhoneNumberConfirmed { get; set; }
public ICollection<AuthorityAttribute> Attributes { get; set; } = [];
public override string ToString() => UserName ?? EmailAddress ?? string.Empty;
}