public async Task <IActionResult> SendPrivateMessage([FromBody] MessagePostDto message) { if (await _userManager.FindByIdAsync(message.ReceiverId) == null) { return(BadRequest(new { Message = $"No user with provided ID { message.ReceiverId } has been found." })); } if (!await _messageService.AddAsync(message, User.FindFirstValue(ClaimTypes.NameIdentifier))) { return(Conflict(new { Error = "Request unsuccessfull." })); } await _messageHub.SendPrivateMessage(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier), message); return(NoContent()); }