/// <summary> /// Broadcast New Like Price /// </summary> private void SqlLikesTableDependencyChanged(object sender, RecordChangedEventArgs <Like> e) { if (e.ChangeType == ChangeType.Insert || e.ChangeType == ChangeType.Update) { var userProfileActor = _userProfileService.GetUserProfile(e.Entity.UserProfileId); var post = _postService.GetPost(e.Entity.PostId); var userProfileTarget = _userProfileService.GetUserProfile(post.UserProfile.Id); Notification notification = null; if (e.Entity.Value == 1) { notification = _notificationService.AddNotification(userProfileTarget.Id, userProfileActor.Name + " liked your post", "", userProfileActor.Name + " liked your post. Click to see your post", "/posts/" + post.Id); } else { notification = _notificationService.AddNotification(userProfileTarget.Id, userProfileActor.Name + " disliked your post", "", userProfileActor.Name + " disliked your post. Click to see your post", "/posts/" + post.Id); } if (notification != null) { var test = GlobalHost.DependencyResolver.Resolve <IConnectionManager>() .GetHubContext <LikeWatcherHub>(); LikeWatcherHub.PushNotification(notification, userProfileTarget.Id); } } }
void SqlFriendRequestsTableDependencyChanged(object sender, RecordChangedEventArgs <FriendRequest> e) { if (e.ChangeType == ChangeType.Insert) { var userProfileActor = _userProfileService.GetUserProfile(e.Entity.InitiatorUserProfileId); var friendRequest = _friendRequestService.GetFriendRequest(e.Entity.Id); var userProfileTarget = _userProfileService.GetUserProfile(friendRequest.TargetUserProfileId); Notification notification = null; notification = _notificationService.AddFriendRequestNotification(userProfileTarget.Id, userProfileActor.Name + " wants to be friends.", "", userProfileActor.Name + " wants to be friends.", "/friend-requests/" + friendRequest.Id, e.Entity.Id.ToString()); if (notification != null) { LikeWatcherHub.PushNotification(notification, userProfileTarget.Id); } } }
private void SqlPostsTableDependencyChanged(object sender, RecordChangedEventArgs <Post> e) { if (e.ChangeType == ChangeType.Insert || e.ChangeType == ChangeType.Update) { var userProfileActor = _userProfileService.GetUserProfile(e.Entity.UserProfileId); var post = _postService.GetPost(e.Entity.Id); if (post.ParentPost == null) { return; } var parentPost = _postService.GetPost(post.ParentPost.Id); var userProfileTarget = _userProfileService.GetUserProfile(parentPost.UserProfile.Id); var notification = _notificationService.AddNotification(userProfileTarget.Id, userProfileActor.Name + " commented your post", "", userProfileActor.Name + " commented your post. Click to see the post", "/posts/" + parentPost.Id); if (notification != null) { LikeWatcherHub.PushNotification(notification, userProfileTarget.Id); } } }