I have this function ("GetUsers") in my API:
private readonly DBCyberCaseTools _context;
public UserController(DBCyberCaseTools context)
{
_context = context;
}
// GET: api/User
[HttpGet]
public async Task<ActionResult<IEnumerable<User>>> GetUsers()
{
if (_context.Users == null)
{
return NotFound();
}
return await _context.Users.ToListAsync();
}
But I don't understand how to use it from another function?
When I call this function, I can't understand how I access the result?
(in swagger it works well)
I'm trying to call it, from function of Login: (UserConstants is just an example class, and now I would like to replace this by calling to "GetUsers".
private UserModel Authenticate(UserLogin userLogin)
{
var currentUser = UserConstants.Users.FirstOrDefault(o => o.Username.ToLower() == userLogin.Username.ToLower() && o.Password == userLogin.Password);
if (currentUser != null)
{
return currentUser;
}
return null;
}
Thank You