added condition for unique role name
This commit is contained in:
parent
17d42f2cdf
commit
7a1a4d6bdb
@ -171,6 +171,13 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
return BadRequest(new { Message = "Feature Permission is required." });
|
return BadRequest(new { Message = "Feature Permission is required." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool roleExists = _context.ApplicationRoles
|
||||||
|
.Any(r => r.TenantId == TenantId && r.Role.ToLower() == createRoleDto.Role.ToLower());// assuming role name is unique per tenant
|
||||||
|
if (roleExists)
|
||||||
|
{
|
||||||
|
return BadRequest(new {message = "Role already exists." });
|
||||||
|
}
|
||||||
ApplicationRole role = createRoleDto.ToApplicationRoleFromCreateDto(TenantId);
|
ApplicationRole role = createRoleDto.ToApplicationRoleFromCreateDto(TenantId);
|
||||||
_context.ApplicationRoles.Add(role);
|
_context.ApplicationRoles.Add(role);
|
||||||
|
|
||||||
@ -198,6 +205,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
if (id != updateRoleDto.Id.ToString())
|
if (id != updateRoleDto.Id.ToString())
|
||||||
return BadRequest("Role ID mismatch");
|
return BadRequest("Role ID mismatch");
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int TenantId = GetTenantId();
|
int TenantId = GetTenantId();
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
// "DefaultConnectionString": "Server=103.50.160.45;User ID=marcowvh_admin;Password=Marcoemp@123;Database=marcowvh_empattendanceci",
|
||||||
|
<<<<<<< Updated upstream
|
||||||
//"DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;Database=MarcoBMS1",
|
//"DefaultConnectionString": "Server=localhost;port=3333;User ID=root;Password=root;Database=MarcoBMS1",
|
||||||
"DefaultConnectionString": "Server=147.93.98.152;User ID=root;Password=MySqlUser@123$;Database=MarcoBMS1"
|
"DefaultConnectionString": "Server=147.93.98.152;User ID=root;Password=MySqlUser@123$;Database=MarcoBMS1"
|
||||||
|
=======
|
||||||
|
"DefaultConnectionString": "Server=localhost;port=3306;User ID=root;Password=root;Database=MarcoBMS1",
|
||||||
|
//"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1"
|
||||||
|
},
|
||||||
|
"AppSettings": {
|
||||||
|
"WebFrontendUrl": "http://localhost:5173",
|
||||||
|
"ImagesBaseUrl": "http://localhost:5173"
|
||||||
|
>>>>>>> Stashed changes
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user