//Helper methods private async Task SendNotification(Follow model) { var notification = new CreateNotificationRequest { ActionOwnerId = model.FollowerId, NotificationType = NotificationType.FollowRequest, PostId = 0, ReiceiverId = model.SubjectId, 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); } }
private async Task SendNotification(int commentOwnerId, Post model) { var createnotificationRequest = new CreateNotificationRequest { ActionOwnerId = commentOwnerId, NotificationType = NotificationType.Commented, PostId = model.Id, ReiceiverId = model.OwnerId, Created = DateTime.Now, Status = Status.Created }; var notification = await _notificationService.CreateNotification(createnotificationRequest); var connections = await _tracker.GetConnectionForUser(notification.ReiceiverId); if (connections != null) { await _presenceHub.Clients.Clients(connections).SendAsync("NewNotification", notification); } }
private async Task SendNotification(int reactionOwnerId, Reaction model) { var notification = new CreateNotificationRequest { ActionOwnerId = reactionOwnerId, Created = DateTime.Now, Status = Status.Created }; if (model.Target == ReactionTarget.Post) { notification.NotificationType = NotificationType.ReactedPost; notification.PostId = model.TargetId; var receiver = await _context.Posts.FindAsync(model.TargetId); notification.ReiceiverId = receiver.OwnerId; } if (model.Target == ReactionTarget.Comment) { notification.NotificationType = NotificationType.ReactedComment; notification.CommentId = model.TargetId; var post = await _context.Comments.FindAsync(model.TargetId); notification.PostId = post.PostId; var receiver = await _context.Comments.FindAsync(model.TargetId); notification.ReiceiverId = receiver.OwnerId; } await _notificationService.CreateNotification(notification); var connections = await _tracker.GetConnectionForUser(notification.ReiceiverId); if (connections != null) { await _presenceHub.Clients.Clients(connections).SendAsync("NewNotification", notification); } }