public async Task <IActionResult> GetMessage(int userId, int id) { // Authorization check if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var messageFromRepo = await _repo.GetMessage(id); if (messageFromRepo == null) { return(NotFound()); } return(Ok(messageFromRepo)); }