added userDtos
All checks were successful
Build and Deploy Frontend / build-and-deploy (push) Successful in 7s
Build and Deploy API / build-and-deploy (push) Successful in 10s

This commit is contained in:
2026-03-28 00:01:45 -05:00
parent 5afd9057f2
commit f271ff59f8
11 changed files with 97 additions and 71 deletions

View File

@@ -23,7 +23,23 @@ public class UsersController : ControllerBase {
[Authorize(Policy = "RequireAdmin")]
[HttpGet]
public async Task<ActionResult<List<User>>> getUsers() {
return Ok(await service_.GetAll());
List<User> rawArray = await service_.GetAll();
List<UserDto> dtoArray = new List<UserDto>();
foreach(User user in rawArray) {
// TODO: can you operator overload a cast? if so cast<UserDto>(UserDto) would go hard
// if not then just a new custom cast function that returns a dto type will do
UserDto newDto = new UserDto{
CreatedAt = user.CreatedAt,
Email = user.Email,
Id = user.Id,
UserName = user.UserName
};
dtoArray.Add(newDto);
}
return Ok(dtoArray);
}
[Authorize(Policy = "RequireAdmin")]
@@ -34,7 +50,14 @@ public class UsersController : ControllerBase {
if (user == null) return NotFound();
return Ok(user);
UserDto newDto = new UserDto{
CreatedAt = user.CreatedAt,
Email = user.Email,
Id = user.Id,
UserName = user.UserName
};
return Ok(newDto);
}
[Authorize(Policy = "RequireSuperuser")]