* Managed API to handle User maintenance

* Managed Users view in application
This commit is contained in:
2025-02-20 06:39:06 +01:00
parent cd5990039d
commit 9b8d621f42
19 changed files with 530 additions and 195 deletions

View File

@@ -7,14 +7,14 @@ namespace OrdersManagementDataModel.Services;
public class RoleService(OrdersManagementDbContext context, IMapper mapper) : IRoleService
{
public async Task<IEnumerable<RoleDto>> GetRoles()
public async Task<IEnumerable<RoleDto>> GetAll()
{
IList<RoleDto> roles = await context.Roles.Select(x => mapper.Map<RoleDto>(x)).ToListAsync();
return roles;
}
public async Task<RoleDto?> GetRoleById(Guid id)
public async Task<RoleDto?> GetById(Guid id)
{
RoleDto? role = await context.Roles.Where(x => x.RowPointer == id)
.Select(x => mapper.Map<RoleDto>(x)).FirstOrDefaultAsync();
@@ -22,7 +22,7 @@ public class RoleService(OrdersManagementDbContext context, IMapper mapper) : IR
return role;
}
public async Task<RoleDto?> GetRoleByName(string name)
public async Task<RoleDto?> GetByName(string name)
{
RoleDto? role = await context.Roles.Where(x => x.Name == name)
.Select(x => mapper.Map<RoleDto>(x)).FirstOrDefaultAsync();
@@ -30,7 +30,7 @@ public class RoleService(OrdersManagementDbContext context, IMapper mapper) : IR
return role;
}
public async Task<int> AddRole(RoleDto roleDto)
public async Task<int> Add(RoleDto roleDto)
{
Role role = new Role
{
@@ -42,7 +42,7 @@ public class RoleService(OrdersManagementDbContext context, IMapper mapper) : IR
return await context.SaveChangesAsync();
}
public async Task<int> DeleteRole(Guid id)
public async Task<int> Delete(Guid id)
{
Role? role = await context.Roles.Where(x => x.RowPointer == id).FirstOrDefaultAsync() ?? null;