Skip to content

Commit c7eb3cd

Browse files
Refactor Implement: adicionando novamente lista de usuários.
1 parent 266aa07 commit c7eb3cd

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

Controllers/LoginController.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ public LoginController(LoginService loginService)
1717
_loginService = loginService;
1818
}
1919

20+
[HttpGet("ListUsers")]
21+
public IActionResult ListUsers()
22+
{
23+
try
24+
{
25+
var listUsers = _loginService.ListUsers();
26+
return Ok(listUsers);
27+
}
28+
catch (Exception ex)
29+
{
30+
return BadRequest("Não foi possível listar os usuários.");
31+
}
32+
}
2033
[HttpPost("CreateAccount")]
2134
public IActionResult CreateAccount([FromBody] UserEntity model)
2235
{

Services/LoginService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ public LoginService(AppDbContext context)
1919
{
2020
_context = context;
2121
}
22-
[HttpGet]
22+
23+
public IActionResult ListUsers ()
24+
{
25+
var users = _context.Users.ToList();
26+
return Ok(users);
27+
}
28+
2329
public IActionResult CreateAccount([FromBody] UserEntity model)
2430
{
2531
if (model != null)

0 commit comments

Comments
 (0)