//Create Notification for posting private async Task SendNotification(Post post) { var follows = await _followService.GetBySubjectId(post.OwnerId); //Create notification for each follower of Post owner foreach (FollowResponse follow in follows) { var notification = new CreateNotificationRequest { //Post Owner ActionOwnerId = post.OwnerId, NotificationType = NotificationType.Posted, PostId = post.Id, ReiceiverId = follow.FollowerId, Created = DateTime.Now, Status = Status.Created }; await _notificationService.CreateNotification(notification); var connections = await _tracker.GetConnectionForUser(notification.ReiceiverId); if (connections != null) { await _presenceHub.Clients.Clients(connections).SendAsync("NewNotification", notification); } } }
public async Task <ActionResult <IEnumerable <FollowResponse> > > GetBySubjectId(int id) { var followers = await _followService.GetBySubjectId(id); foreach (FollowResponse follower in followers) { var followState = await _followService.GetState(follower.FollowerId, Account.Id); follower.isFollower_FollowedByCurrentUser = followState.IsCreated; } return(Ok(followers)); }