85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Identity;
|
|
using Wishlist.Data.DB;
|
|
|
|
namespace Wishlist.Models;
|
|
|
|
public class ApplicationUser : IdentityUser<string>
|
|
{
|
|
DatabaseModel _database;
|
|
|
|
public ApplicationUser(DatabaseModel database)
|
|
{
|
|
_database = database;
|
|
Id = Guid.NewGuid().ToString();
|
|
}
|
|
|
|
public User User { get; set; } = new();
|
|
|
|
//public string Name { get; set; } => string.Empty;
|
|
//public string GivenName { get; set; } = String.Empty;
|
|
//public string Surname { get; set; } = String.Empty;
|
|
|
|
public string Name
|
|
{
|
|
get => User.Name ?? string.Empty;
|
|
set => User.Name = value;
|
|
}
|
|
public string GivenName
|
|
{
|
|
get => User.GivenName ?? string.Empty;
|
|
set => User.GivenName = value;
|
|
}
|
|
public string Surname
|
|
{
|
|
get => User.Surname ?? string.Empty;
|
|
set => User.Surname = value;
|
|
}
|
|
|
|
public virtual ICollection<ApplicationUserClaim> Claims { get; set; }
|
|
public virtual ICollection<ApplicationUserLogin> Logins { get; set; }
|
|
public virtual ICollection<ApplicationUserToken> Tokens { get; set; }
|
|
public virtual ICollection<ApplicationUserRole> UserRoles { get; set; }
|
|
|
|
public async Task SaveToDb() => await _database.Users.InsertAsync(User);
|
|
}
|
|
|
|
public class ApplicationRole : IdentityRole<string>
|
|
{
|
|
public ApplicationRole()
|
|
{
|
|
Id = Guid.NewGuid().ToString();
|
|
}
|
|
|
|
public override string Id { get; set; }
|
|
|
|
public string Description { get; set; }
|
|
|
|
public virtual ICollection<ApplicationUserRole> UserRoles { get; set; }
|
|
public virtual ICollection<ApplicationRoleClaim> RoleClaims { get; set; }
|
|
}
|
|
|
|
public class ApplicationUserRole : IdentityUserRole<string>
|
|
{
|
|
public virtual ApplicationUser User { get; set; }
|
|
public virtual ApplicationRole Role { get; set; }
|
|
}
|
|
|
|
public class ApplicationUserClaim : IdentityUserClaim<string>
|
|
{
|
|
public virtual ApplicationUser User { get; set; }
|
|
}
|
|
|
|
public class ApplicationUserLogin : IdentityUserLogin<string>
|
|
{
|
|
public virtual ApplicationUser User { get; set; }
|
|
}
|
|
|
|
public class ApplicationRoleClaim : IdentityRoleClaim<string>
|
|
{
|
|
public virtual ApplicationRole Role { get; set; }
|
|
}
|
|
|
|
public class ApplicationUserToken : IdentityUserToken<string>
|
|
{
|
|
public virtual ApplicationUser User { get; set; }
|
|
} |