public async Task <IActionResult> GetMessage(int userId, int id) { 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)); }