Add support for multiple roles
This commit is contained in:
parent
d17291af6c
commit
f73cdc1331
7 changed files with 38 additions and 5 deletions
9
NG_2023_Kanban.BusinessLayer/Enums/UserRoles.cs
Normal file
9
NG_2023_Kanban.BusinessLayer/Enums/UserRoles.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace NG_2023_Kanban.BusinessLayer.Enums
|
||||||
|
{
|
||||||
|
public enum Roles
|
||||||
|
{
|
||||||
|
User,
|
||||||
|
Manager,
|
||||||
|
Administrator
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
using NG_2023_Kanban.BusinessLayer.Enums;
|
||||||
|
|
||||||
namespace NG_2023_Kanban.BusinessLayer.Models
|
namespace NG_2023_Kanban.BusinessLayer.Models
|
||||||
{
|
{
|
||||||
public class UserModel : BaseModel
|
public class UserModel : BaseModel
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
public bool IsAdmin { get; set; } = false;
|
public int Role { get; set; } = (int)Roles.User;
|
||||||
|
|
||||||
public virtual ICollection<BoardModel>? Boards { get; set; } = new HashSet<BoardModel>();
|
public virtual ICollection<BoardModel>? Boards { get; set; } = new HashSet<BoardModel>();
|
||||||
public virtual ICollection<CardModel>? Cards { get; set; } = new HashSet<CardModel>();
|
public virtual ICollection<CardModel>? Cards { get; set; } = new HashSet<CardModel>();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using NG_2023_Kanban.DataLayer.Enums;
|
||||||
|
|
||||||
namespace NG_2023_Kanban.DataLayer.Entities
|
namespace NG_2023_Kanban.DataLayer.Entities
|
||||||
{
|
{
|
||||||
public class User : BaseEntity
|
public class User : BaseEntity
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
public bool IsAdmin { get; set; } = false;
|
public int Role { get; set; } = (int)Roles.User;
|
||||||
|
|
||||||
public virtual ICollection<Board>? Boards { get; set; } = new HashSet<Board>();
|
public virtual ICollection<Board>? Boards { get; set; } = new HashSet<Board>();
|
||||||
public virtual ICollection<Card>? Cards { get; set; } = new HashSet<Card>();
|
public virtual ICollection<Card>? Cards { get; set; } = new HashSet<Card>();
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace NG_2023_Kanban.DataLayer.EntityConfiguration
|
||||||
builder.Property(x => x.Username).IsRequired();
|
builder.Property(x => x.Username).IsRequired();
|
||||||
builder.Property(x => x.Password).IsRequired();
|
builder.Property(x => x.Password).IsRequired();
|
||||||
|
|
||||||
builder.Property(x => x.IsAdmin).IsRequired();
|
builder.Property(x => x.Role).IsRequired();
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasMany(x => x.Boards)
|
.HasMany(x => x.Boards)
|
||||||
|
|
9
NG_2023_Kanban.DataLayer/Enums/UserRoles.cs
Normal file
9
NG_2023_Kanban.DataLayer/Enums/UserRoles.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace NG_2023_Kanban.DataLayer.Enums
|
||||||
|
{
|
||||||
|
public enum Roles
|
||||||
|
{
|
||||||
|
User,
|
||||||
|
Manager,
|
||||||
|
Administrator
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
namespace NG_2023_Kanban.DTOs
|
using NG_2023_Kanban.Enums;
|
||||||
|
|
||||||
|
namespace NG_2023_Kanban.DTOs
|
||||||
{
|
{
|
||||||
public class UserDto : BaseDto
|
public class UserDto : BaseDto
|
||||||
{
|
{
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
public bool IsAdmin { get; set; } = false;
|
public int Role { get; set; } = (int)Roles.User;
|
||||||
|
|
||||||
public virtual ICollection<BoardDto>? Boards { get; set; } = new HashSet<BoardDto>();
|
public virtual ICollection<BoardDto>? Boards { get; set; } = new HashSet<BoardDto>();
|
||||||
public virtual ICollection<CardDto>? Cards { get; set; } = new HashSet<CardDto>();
|
public virtual ICollection<CardDto>? Cards { get; set; } = new HashSet<CardDto>();
|
||||||
|
|
9
NG_2023_Kanban/Enums/UserRoles.cs
Normal file
9
NG_2023_Kanban/Enums/UserRoles.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace NG_2023_Kanban.Enums
|
||||||
|
{
|
||||||
|
public enum Roles
|
||||||
|
{
|
||||||
|
User,
|
||||||
|
Manager,
|
||||||
|
Administrator
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue