public async Task <IActionResult> AddPostDescription(NewPostRequestDto newPost) { try { var userId = int.Parse(HttpContext.User.Identity.Name); var post = await _postService.AddNewPost(newPost, userId); await _notificationService.AddNewPostNotification(userId); var connections = await _connectionService.GetFriendsConnectionId(userId); var postJson = JsonConvert.SerializeObject(new { postContent = post.PostContent, postId = post.PostId, username = post.PostOwner.Username, postImage = post.PostImage, profilePicture = post.PostOwner.ProfilePicture }); await _hubContext.Clients.Clients(connections).SendAsync("NewPostNotification", postJson); return(Ok(true)); } catch (Exception ex) { return(BadRequest(ex)); } }