Minor fixes for CreateUser
This commit is contained in:
@@ -13,6 +13,7 @@ public interface IRoleService
|
||||
Task<Role?> GetRoleByGuidAsync(string guid);
|
||||
Task<bool> CheckIfNameIsValid(string name, string? guid = "");
|
||||
Task<Role?> CreateRole(CreateRoleRequestData data);
|
||||
Task<Role?> GetRoleForUser(string? guid);
|
||||
}
|
||||
|
||||
public class RoleService : BaseService, IRoleService
|
||||
@@ -36,6 +37,8 @@ public class RoleService : BaseService, IRoleService
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Role CreateRoleData(CreateRoleRequestData data)
|
||||
{
|
||||
Role role = new()
|
||||
@@ -52,6 +55,9 @@ public class RoleService : BaseService, IRoleService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<Role?> GetRoleByIdAsync(int id)
|
||||
{
|
||||
return await this.GetRolesQueryable().Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
@@ -98,6 +104,20 @@ public class RoleService : BaseService, IRoleService
|
||||
return role;
|
||||
}
|
||||
|
||||
public async Task<Role?> GetRoleForUser(string? guid)
|
||||
{
|
||||
Role? role = null;
|
||||
|
||||
if (String.IsNullOrEmpty(guid))
|
||||
{
|
||||
role = await this.GetRoleByNameQueryable("Default").FirstOrDefaultAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
role = await this.GetRoleByGuidAsync(guid);
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user