diff --git a/NG_2023_Kanban.BusinessLayer/Enums/UserRoles.cs b/NG_2023_Kanban.BusinessLayer/Enums/UserRoles.cs deleted file mode 100644 index d0d0b90..0000000 --- a/NG_2023_Kanban.BusinessLayer/Enums/UserRoles.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NG_2023_Kanban.BusinessLayer.Enums -{ - public enum Roles - { - User, - Manager, - Administrator - } -} diff --git a/NG_2023_Kanban.BusinessLayer/Interfaces/IUserService.cs b/NG_2023_Kanban.BusinessLayer/Interfaces/IUserService.cs index e660f2d..862b95e 100644 --- a/NG_2023_Kanban.BusinessLayer/Interfaces/IUserService.cs +++ b/NG_2023_Kanban.BusinessLayer/Interfaces/IUserService.cs @@ -10,5 +10,6 @@ namespace NG_2023_Kanban.BusinessLayer.Interfaces Task UpdateAsync(int id, UserModel user); Task LoginAsync(UserModel user); Task RegisterAsync(UserModel user); + Task CheckAdminAsync(int id); } } diff --git a/NG_2023_Kanban.BusinessLayer/MappingProfile.cs b/NG_2023_Kanban.BusinessLayer/MappingProfile.cs index 39e3de8..f6dc358 100644 --- a/NG_2023_Kanban.BusinessLayer/MappingProfile.cs +++ b/NG_2023_Kanban.BusinessLayer/MappingProfile.cs @@ -20,6 +20,9 @@ namespace NG_2023_Kanban.BusinessLayer CreateMap() .ReverseMap(); + CreateMap() + .ReverseMap(); + CreateMap() .ReverseMap(); } diff --git a/NG_2023_Kanban.BusinessLayer/Models/CardModel.cs b/NG_2023_Kanban.BusinessLayer/Models/CardModel.cs index 98a13ff..36a5575 100644 --- a/NG_2023_Kanban.BusinessLayer/Models/CardModel.cs +++ b/NG_2023_Kanban.BusinessLayer/Models/CardModel.cs @@ -4,11 +4,13 @@ { public string Name { get; set; } public string Description { get; set; } - public int SenderId { get; set; } + public int AssignedId { get; set; } public int ColumnId { get; set; } + public int SenderId { get; set; } - public virtual UserModel Sender { get; set; } + public virtual UserModel Assigned { get; set; } public virtual ColumnModel Column { get; set; } + public virtual UserModel Sender { get; set; } public virtual ICollection Comments { get; set; } = new HashSet(); } diff --git a/NG_2023_Kanban.BusinessLayer/Models/RoleModel.cs b/NG_2023_Kanban.BusinessLayer/Models/RoleModel.cs new file mode 100644 index 0000000..d63d5d8 --- /dev/null +++ b/NG_2023_Kanban.BusinessLayer/Models/RoleModel.cs @@ -0,0 +1,9 @@ +namespace NG_2023_Kanban.BusinessLayer.Models +{ + public class RoleModel : BaseModel + { + public string Name { get; set; } + + public virtual ICollection? Members { get; set; } = new HashSet(); + } +} diff --git a/NG_2023_Kanban.BusinessLayer/Models/UserModel.cs b/NG_2023_Kanban.BusinessLayer/Models/UserModel.cs index f93c808..fcf7847 100644 --- a/NG_2023_Kanban.BusinessLayer/Models/UserModel.cs +++ b/NG_2023_Kanban.BusinessLayer/Models/UserModel.cs @@ -1,6 +1,4 @@ -using NG_2023_Kanban.BusinessLayer.Enums; - -namespace NG_2023_Kanban.BusinessLayer.Models +namespace NG_2023_Kanban.BusinessLayer.Models { public class UserModel : BaseModel { @@ -9,10 +7,10 @@ using NG_2023_Kanban.BusinessLayer.Enums; public string Username { get; set; } public string Password { get; set; } - public int Role { get; set; } = (int)Roles.User; - public virtual ICollection? Boards { get; set; } = new HashSet(); - public virtual ICollection? Cards { get; set; } = new HashSet(); + public virtual ICollection? CardsAssigned { get; set; } = new HashSet(); + public virtual ICollection? CardsSent { get; set; } = new HashSet(); public virtual ICollection? Comments { get; set; } = new HashSet(); + public virtual ICollection? Roles { get; set; } = new HashSet(); } } diff --git a/NG_2023_Kanban.BusinessLayer/Service/UserService.cs b/NG_2023_Kanban.BusinessLayer/Service/UserService.cs index de9ac8c..88ddb1f 100644 --- a/NG_2023_Kanban.BusinessLayer/Service/UserService.cs +++ b/NG_2023_Kanban.BusinessLayer/Service/UserService.cs @@ -54,5 +54,20 @@ namespace NG_2023_Kanban.BusinessLayer.Services await _userRepository.CreateAsync(entity); return _mapper.Map(entity); } + + public async Task CheckAdminAsync(int id) + { + var user = await GetAsync(id); + + Console.WriteLine(user.Roles.Count); + foreach (RoleModel role in user.Roles) + { + if (role.Name == "Administrator") + { + return true; + } + } + return false; + } } } diff --git a/NG_2023_Kanban.DataLayer/DbStartup/DatabaseContext.cs b/NG_2023_Kanban.DataLayer/DbStartup/DatabaseContext.cs index 7886c58..e48ce17 100644 --- a/NG_2023_Kanban.DataLayer/DbStartup/DatabaseContext.cs +++ b/NG_2023_Kanban.DataLayer/DbStartup/DatabaseContext.cs @@ -12,6 +12,7 @@ namespace NG_2023_Kanban.DataLayer.DbStartup public DbSet Cards { get; set; } public DbSet Columns { get; set; } public DbSet Comments { get; set; } + public DbSet Roles { get; set; } public DbSet Users { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/NG_2023_Kanban.DataLayer/DbStartup/Injecting.cs b/NG_2023_Kanban.DataLayer/DbStartup/Injecting.cs index df088ec..fdfa295 100644 --- a/NG_2023_Kanban.DataLayer/DbStartup/Injecting.cs +++ b/NG_2023_Kanban.DataLayer/DbStartup/Injecting.cs @@ -16,6 +16,7 @@ namespace NG_2023_Kanban.DataLayer.DbStartup services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddDbContext(options => diff --git a/NG_2023_Kanban.DataLayer/Entities/Card.cs b/NG_2023_Kanban.DataLayer/Entities/Card.cs index 04e9700..d61df48 100644 --- a/NG_2023_Kanban.DataLayer/Entities/Card.cs +++ b/NG_2023_Kanban.DataLayer/Entities/Card.cs @@ -4,11 +4,13 @@ { public string Name { get; set; } public string Description { get; set; } - public int SenderId { get; set; } + public int AssignedId { get; set; } public int ColumnId { get; set; } + public int SenderId { get; set; } - public virtual User Sender { get; set; } + public virtual User Assigned { get; set; } public virtual Column Column { get; set; } + public virtual User Sender { get; set; } public virtual ICollection Comments { get; set; } = new HashSet(); } diff --git a/NG_2023_Kanban.DataLayer/Entities/Role.cs b/NG_2023_Kanban.DataLayer/Entities/Role.cs new file mode 100644 index 0000000..19b9818 --- /dev/null +++ b/NG_2023_Kanban.DataLayer/Entities/Role.cs @@ -0,0 +1,9 @@ +namespace NG_2023_Kanban.DataLayer.Entities +{ + public class Role : BaseEntity + { + public string Name { get; set; } + + public virtual ICollection? Members { get; set; } = new HashSet(); + } +} diff --git a/NG_2023_Kanban.DataLayer/Entities/User.cs b/NG_2023_Kanban.DataLayer/Entities/User.cs index e87e0f3..16fe1c9 100644 --- a/NG_2023_Kanban.DataLayer/Entities/User.cs +++ b/NG_2023_Kanban.DataLayer/Entities/User.cs @@ -1,6 +1,4 @@ -using NG_2023_Kanban.DataLayer.Enums; - -namespace NG_2023_Kanban.DataLayer.Entities +namespace NG_2023_Kanban.DataLayer.Entities { public class User : BaseEntity { @@ -9,10 +7,10 @@ using NG_2023_Kanban.DataLayer.Enums; public string Username { get; set; } public string Password { get; set; } - public int Role { get; set; } = (int)Roles.User; - public virtual ICollection? Boards { get; set; } = new HashSet(); - public virtual ICollection? Cards { get; set; } = new HashSet(); + public virtual ICollection? CardsAssigned { get; set; } = new HashSet(); public virtual ICollection? Comments { get; set; } = new HashSet(); + public virtual ICollection? CardsSent { get; set; } = new HashSet(); + public virtual ICollection? Roles { get; set; } = new HashSet(); } } diff --git a/NG_2023_Kanban.DataLayer/EntityConfiguration/CardConfiguration.cs b/NG_2023_Kanban.DataLayer/EntityConfiguration/CardConfiguration.cs index a589570..9b42043 100644 --- a/NG_2023_Kanban.DataLayer/EntityConfiguration/CardConfiguration.cs +++ b/NG_2023_Kanban.DataLayer/EntityConfiguration/CardConfiguration.cs @@ -18,9 +18,9 @@ namespace NG_2023_Kanban.DataLayer.EntityConfiguration builder.Property(x => x.Description).HasMaxLength(100); builder - .HasOne(x => x.Sender) - .WithMany(x => x.Cards) - .HasForeignKey(x => x.SenderId) + .HasOne(x => x.Assigned) + .WithMany(x => x.CardsAssigned) + .HasForeignKey(x => x.AssignedId) .HasPrincipalKey(x => x.Id); builder @@ -28,6 +28,12 @@ namespace NG_2023_Kanban.DataLayer.EntityConfiguration .WithMany(x => x.Cards) .HasForeignKey(x => x.ColumnId) .HasPrincipalKey(x => x.Id); + + builder + .HasOne(x => x.Sender) + .WithMany(x => x.CardsSent) + .HasForeignKey(x => x.SenderId) + .HasPrincipalKey(x => x.Id); } } } diff --git a/NG_2023_Kanban.DataLayer/EntityConfiguration/UserConfiguration.cs b/NG_2023_Kanban.DataLayer/EntityConfiguration/UserConfiguration.cs index a55edde..631d70f 100644 --- a/NG_2023_Kanban.DataLayer/EntityConfiguration/UserConfiguration.cs +++ b/NG_2023_Kanban.DataLayer/EntityConfiguration/UserConfiguration.cs @@ -18,11 +18,13 @@ namespace NG_2023_Kanban.DataLayer.EntityConfiguration builder.Property(x => x.Username).IsRequired(); builder.Property(x => x.Password).IsRequired(); - builder.Property(x => x.Role).IsRequired(); - builder .HasMany(x => x.Boards) .WithMany(x => x.Users); + + builder + .HasMany(x => x.Roles) + .WithMany(x => x.Members); } } } diff --git a/NG_2023_Kanban.DataLayer/Enums/UserRoles.cs b/NG_2023_Kanban.DataLayer/Enums/UserRoles.cs deleted file mode 100644 index bc4940a..0000000 --- a/NG_2023_Kanban.DataLayer/Enums/UserRoles.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NG_2023_Kanban.DataLayer.Enums -{ - public enum Roles - { - User, - Manager, - Administrator - } -} diff --git a/NG_2023_Kanban.DataLayer/Interfaces/IRoleRepository.cs b/NG_2023_Kanban.DataLayer/Interfaces/IRoleRepository.cs new file mode 100644 index 0000000..0fd1169 --- /dev/null +++ b/NG_2023_Kanban.DataLayer/Interfaces/IRoleRepository.cs @@ -0,0 +1,8 @@ +using NG_2023_Kanban.DataLayer.Entities; + +namespace NG_2023_Kanban.DataLayer.Interfaces +{ + public interface IRoleRepository : IRepository + { + } +} diff --git a/NG_2023_Kanban.DataLayer/Repositories/RoleRepository.cs b/NG_2023_Kanban.DataLayer/Repositories/RoleRepository.cs new file mode 100644 index 0000000..bd3db72 --- /dev/null +++ b/NG_2023_Kanban.DataLayer/Repositories/RoleRepository.cs @@ -0,0 +1,10 @@ +using NG_2023_Kanban.DataLayer.DbStartup; +using NG_2023_Kanban.DataLayer.Entities; +using NG_2023_Kanban.DataLayer.Interfaces; + +namespace NG_2023_Kanban.DataLayer.Repositories; + +public class RoleRepository : BaseRepository, IRoleRepository +{ + public RoleRepository(DatabaseContext context) : base(context) { } +} diff --git a/NG_2023_Kanban/Controllers/AdminController.cs b/NG_2023_Kanban/Controllers/AdminController.cs index 0eb7974..a64c54f 100644 --- a/NG_2023_Kanban/Controllers/AdminController.cs +++ b/NG_2023_Kanban/Controllers/AdminController.cs @@ -1,10 +1,10 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Http; using AutoMapper; using NG_2023_Kanban.Models; using NG_2023_Kanban.DTOs; -using NG_2023_Kanban.Enums; using NG_2023_Kanban.BusinessLayer.Models; using NG_2023_Kanban.BusinessLayer.Services; @@ -25,129 +25,86 @@ public class AdminController : Controller _mapper = mapper; } - public async Task Boards() + public override async void OnActionExecuting(ActionExecutingContext actionContext) { var currentAccount = HttpContext.Session.GetInt32("Account"); if (currentAccount.HasValue) { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - ViewData["Boards"] = _mapper.Map>(await _boardService.GetAllAsync()); - return View(); + var userModel = await _userService.GetAsync(currentAccount.Value); + bool isAdmin = await _userService.CheckAdminAsync(userModel.Id); + if (!isAdmin) + { + actionContext.Result = StatusCode(403); + return; + } + ViewData["Account"] = _mapper.Map(userModel);; + ViewData["isAdmin"] = true; } - return Redirect("/Auth/Login"); + else + actionContext.Result = Redirect("/Auth/Login"); + } + + public async Task Boards() + { + ViewData["Boards"] = _mapper.Map>(await _boardService.GetAllAsync()); + return View(); } public async Task Users() { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) - { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - ViewData["Users"] = _mapper.Map>(await _userService.GetAllAsync()); - return View(); - } - return Redirect("/Auth/Login"); + ViewData["Users"] = _mapper.Map>(await _userService.GetAllAsync()); + return View(); } public async Task EditUser(int id) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) - { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - ViewData["EditedAccount"] = _mapper.Map(await _userService.GetAsync(id)); - return View(); - } - return Redirect("/Auth/Login"); + ViewData["EditedAccount"] = _mapper.Map(await _userService.GetAsync(id)); + return View(); } [HttpPost] public async Task EditUser(int id, UserDto user) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) - { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - ViewData["EditedAccount"] = _mapper.Map(await _userService.GetAsync(id)); - //try - //{ - user.Id = id; - var model = _mapper.Map(user); - await _userService.UpdateAsync(id, model); - return Redirect("/Admin/Users"); - //} - //catch - //{ - // ViewData["Error"] = "This name is already taken."; - // return View(); - //} - } - return Redirect("/Auth/Login"); + ViewData["EditedAccount"] = _mapper.Map(await _userService.GetAsync(id)); + //try + //{ + user.Id = id; + var model = _mapper.Map(user); + await _userService.UpdateAsync(id, model); + return Redirect("/Admin/Users"); + //} + //catch + //{ + // ViewData["Error"] = "This name is already taken."; + // return View(); + //} } - public async Task CreateUser() + public IActionResult CreateUser() { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) - { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - return View(); - } - return Redirect("/Auth/Login"); + return View(); } [HttpPost] public async Task CreateUser(UserDto user) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) + try { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - ViewData["Account"] = account; - try - { - var model = _mapper.Map(user); - await _userService.RegisterAsync(model); - return Redirect("/Admin/Users"); - } - catch - { - ViewData["Error"] = "This name is already taken."; - return View(); - } + var model = _mapper.Map(user); + await _userService.RegisterAsync(model); + return Redirect("/Admin/Users"); + } + catch + { + ViewData["Error"] = "This name is already taken."; + return View(); } - return Redirect("/Auth/Login"); } public async Task DeleteUser(int id) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount.HasValue) - { - var account = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - if (account.Role < (int)Roles.Administrator) - return StatusCode(StatusCodes.Status403Forbidden); - await _userService.DeleteAsync(id); - return Redirect("/Admin/Users"); - } - return Redirect("/Auth/Login"); + await _userService.DeleteAsync(id); + return Redirect("/Admin/Users"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/NG_2023_Kanban/Controllers/AuthController.cs b/NG_2023_Kanban/Controllers/AuthController.cs index fc8fbe9..5e216e9 100644 --- a/NG_2023_Kanban/Controllers/AuthController.cs +++ b/NG_2023_Kanban/Controllers/AuthController.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; using AutoMapper; using NG_2023_Kanban.Models; using NG_2023_Kanban.DTOs; @@ -21,22 +22,21 @@ public class AuthController : Controller _mapper = mapper; } - public IActionResult Login() + public override void OnActionExecuting(ActionExecutingContext actionContext) { var currentAccount = HttpContext.Session.GetInt32("Account"); if (currentAccount != null) - return Redirect("/Home/Index"); + actionContext.Result = Redirect("Home/Index"); + } + public IActionResult Login() + { return View(); } [HttpPost] public async Task Login(UserDto user) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount != null) - return Redirect("/Home/Index"); - var model = _mapper.Map(user); var account = _mapper.Map(await _userService.LoginAsync(model)); @@ -53,28 +53,14 @@ public class AuthController : Controller } } - public IActionResult Logout() - { - HttpContext.Session.Remove("Account"); - return Redirect("/Auth/Login"); - } - public IActionResult Register() { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount != null) - return Redirect("/Home/Index"); - return View(); } [HttpPost] public async Task Register(UserDto user) { - var currentAccount = HttpContext.Session.GetInt32("Account"); - if (currentAccount != null) - return Redirect("/Home/Index"); - try { var model = _mapper.Map(user); diff --git a/NG_2023_Kanban/Controllers/HomeController.cs b/NG_2023_Kanban/Controllers/HomeController.cs index ee39df0..f81c519 100644 --- a/NG_2023_Kanban/Controllers/HomeController.cs +++ b/NG_2023_Kanban/Controllers/HomeController.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; using AutoMapper; using NG_2023_Kanban.Models; using NG_2023_Kanban.DTOs; @@ -21,14 +22,27 @@ public class HomeController : Controller _mapper = mapper; } - public async Task Index() + public override async void OnActionExecuting(ActionExecutingContext actionContext) { var currentAccount = HttpContext.Session.GetInt32("Account"); if (currentAccount.HasValue) { - ViewData["Account"] = _mapper.Map(await _userService.GetAsync(currentAccount.Value)); - return View(); + var userModel = await _userService.GetAsync(currentAccount.Value); + ViewData["Account"] = _mapper.Map(userModel); + ViewData["isAdmin"] = await _userService.CheckAdminAsync(userModel.Id); } + else + actionContext.Result = Redirect("/Auth/Login"); + } + + public IActionResult Index() + { + return View(); + } + + public IActionResult Logout() + { + HttpContext.Session.Remove("Account"); return Redirect("/Auth/Login"); } diff --git a/NG_2023_Kanban/DTOs/CardDto.cs b/NG_2023_Kanban/DTOs/CardDto.cs index 5b6fdf4..96a784f 100644 --- a/NG_2023_Kanban/DTOs/CardDto.cs +++ b/NG_2023_Kanban/DTOs/CardDto.cs @@ -4,11 +4,13 @@ { public string Name { get; set; } public string Description { get; set; } - public int SenderId { get; set; } + public int AssignedId { get; set; } public int ColumnId { get; set; } + public int SenderId { get; set; } - public virtual UserDto Sender { get; set; } + public virtual UserDto Assigned { get; set; } public virtual ColumnDto Column { get; set; } + public virtual UserDto Sender { get; set; } public virtual ICollection Comments { get; set; } = new HashSet(); } diff --git a/NG_2023_Kanban/DTOs/RoleDto.cs b/NG_2023_Kanban/DTOs/RoleDto.cs new file mode 100644 index 0000000..eb20f4a --- /dev/null +++ b/NG_2023_Kanban/DTOs/RoleDto.cs @@ -0,0 +1,9 @@ +namespace NG_2023_Kanban.DTOs +{ + public class RoleDto : BaseDto + { + public string Name { get; set; } + + public virtual ICollection? Members { get; set; } = new HashSet(); + } +} diff --git a/NG_2023_Kanban/DTOs/UserDto.cs b/NG_2023_Kanban/DTOs/UserDto.cs index c32782b..3c816f1 100644 --- a/NG_2023_Kanban/DTOs/UserDto.cs +++ b/NG_2023_Kanban/DTOs/UserDto.cs @@ -1,5 +1,3 @@ -using NG_2023_Kanban.Enums; - namespace NG_2023_Kanban.DTOs { public class UserDto : BaseDto @@ -9,10 +7,10 @@ namespace NG_2023_Kanban.DTOs public string Username { get; set; } public string Password { get; set; } - public int Role { get; set; } = (int)Roles.User; - public virtual ICollection? Boards { get; set; } = new HashSet(); - public virtual ICollection? Cards { get; set; } = new HashSet(); + public virtual ICollection? CardsAssigned { get; set; } = new HashSet(); + public virtual ICollection? CardsSent { get; set; } = new HashSet(); public virtual ICollection? Comments { get; set; } = new HashSet(); + public virtual ICollection? Roles { get; set; } = new HashSet(); } } diff --git a/NG_2023_Kanban/Enums/UserRoles.cs b/NG_2023_Kanban/Enums/UserRoles.cs deleted file mode 100644 index 451f02f..0000000 --- a/NG_2023_Kanban/Enums/UserRoles.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NG_2023_Kanban.Enums -{ - public enum Roles - { - User, - Manager, - Administrator - } -} diff --git a/NG_2023_Kanban/MappingProfile.cs b/NG_2023_Kanban/MappingProfile.cs index a23ac3b..a60e283 100644 --- a/NG_2023_Kanban/MappingProfile.cs +++ b/NG_2023_Kanban/MappingProfile.cs @@ -20,6 +20,9 @@ namespace NG_2023_Kanban CreateMap() .ReverseMap(); + CreateMap() + .ReverseMap(); + CreateMap() .ReverseMap(); } diff --git a/NG_2023_Kanban/Views/Admin/CreateUser.cshtml b/NG_2023_Kanban/Views/Admin/CreateUser.cshtml index 207297d..84f308f 100644 --- a/NG_2023_Kanban/Views/Admin/CreateUser.cshtml +++ b/NG_2023_Kanban/Views/Admin/CreateUser.cshtml @@ -1,5 +1,3 @@ -@using NG_2023_Kanban.Enums - @using NG_2023_Kanban.DTOs @{ ViewData["Title"] = "Create user"; @@ -18,16 +16,6 @@


-
-
diff --git a/NG_2023_Kanban/Views/Admin/EditUser.cshtml b/NG_2023_Kanban/Views/Admin/EditUser.cshtml index c2a7bc3..b33d007 100644 --- a/NG_2023_Kanban/Views/Admin/EditUser.cshtml +++ b/NG_2023_Kanban/Views/Admin/EditUser.cshtml @@ -1,5 +1,3 @@ -@using NG_2023_Kanban.Enums - @using NG_2023_Kanban.DTOs @{ var user = ViewData["EditedAccount"] as UserDto; @@ -22,23 +20,6 @@


-
-
diff --git a/NG_2023_Kanban/Views/Shared/_Layout.cshtml b/NG_2023_Kanban/Views/Shared/_Layout.cshtml index dea1503..aa93dc6 100644 --- a/NG_2023_Kanban/Views/Shared/_Layout.cshtml +++ b/NG_2023_Kanban/Views/Shared/_Layout.cshtml @@ -1,6 +1,4 @@ -@using NG_2023_Kanban.Enums - -@using NG_2023_Kanban.DTOs +@using NG_2023_Kanban.DTOs @{ var user = ViewData["Account"] as UserDto; } @@ -31,7 +29,7 @@ - if (user.Role == (int)Roles.Administrator) + if ((bool)ViewData["isAdmin"]) {