Get users and role and add user row
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 57s

This commit is contained in:
2025-04-26 21:03:58 +02:00
parent 851f0b5af1
commit 065de43d6c
19 changed files with 325 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
using GameIdeas.Shared.Dto;
using GameIdeas.Shared.Constants;
using GameIdeas.Shared.Dto;
using GameIdeas.WebAPI.Exceptions;
using GameIdeas.WebAPI.Services.Users;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GameIdeas.WebAPI.Controllers;
@@ -36,4 +38,34 @@ public class UserController(
return StatusCode(500, e.Message);
}
}
[Authorize(Roles = GlobalConstants.ADMINISTRATOR)]
[HttpGet("Roles")]
public async Task<ActionResult<IEnumerable<RoleDto>>> GetRoles()
{
try
{
return Ok(await userService.GetRoles());
}
catch (Exception e)
{
logger.LogError(e, "Internal error while get roles");
return StatusCode(500, e.Message);
}
}
[Authorize(Roles = GlobalConstants.ADMINISTRATOR)]
[HttpGet]
public async Task<ActionResult<UserListDto>> GetUsers([FromQuery] UserFilterDto filter)
{
try
{
return Ok(await userService.GetUsers(filter));
}
catch (Exception e)
{
logger.LogError(e, "Internal error while get users");
return StatusCode(500, e.Message);
}
}
}