示例#1
0
        public async Task NotifyAsync(NewPostDto postModel, NewlyCreatedPostDto createdPost, UserAndOrganizationHubDto userHubDto)
        {
            await _postNotificationService.NotifyAboutNewPostAsync(createdPost);

            var membersToNotify = await _wallService.GetWallMembersIdsAsync(postModel.WallId, postModel);

            await NotificationHub.SendWallNotificationAsync(postModel.WallId, membersToNotify, createdPost.WallType, userHubDto);
        }
示例#2
0
        public async Task <NotificationDto> CreateForWallAsync(UserAndOrganizationDto userOrg, CreateWallDto wallDto, int wallId)
        {
            var mainWallId = await _wallDbSet.Where(w => w.Type == WallType.Main).Select(s => s.Id).SingleAsync();

            var membersToNotify = await _wallService.GetWallMembersIdsAsync(mainWallId, userOrg);

            var newNotification = Notification.Create(wallDto.Name, wallDto.Description, wallDto.Logo, new Sources {
                WallId = wallId
            }, NotificationType.NewWall, userOrg.OrganizationId, membersToNotify);

            _notificationDbSet.Add(newNotification);

            await _uow.SaveChangesAsync();

            return(_mapper.Map <NotificationDto>(newNotification));
        }
示例#3
0
        public async Task <NotificationDto> CreateForEventAsync(UserAndOrganizationDto userOrg, CreateEventDto eventDto)
        {
            var mainWallId = await _wallDbSet.Where(w => w.Type == WallType.Main).Select(s => s.Id).SingleAsync();

            var membersToNotify = await _wallService.GetWallMembersIdsAsync(mainWallId, userOrg);

            var sourceIds = new Sources {
                EventId = eventDto.Id
            };
            var newNotification = Notification.Create(eventDto.Name, eventDto.Description, eventDto.ImageName, sourceIds, NotificationType.NewEvent, userOrg.OrganizationId, membersToNotify);

            _notificationDbSet.Add(newNotification);

            await _uow.SaveChangesAsync();

            return(_mapper.Map <NotificationDto>(newNotification));
        }
示例#4
0
        public async Task NotifyAsync(CommentCreatedDto commentDto, UserAndOrganizationHubDto userHubDto)
        {
            await _commentEmailNotificationService.SendEmailNotificationAsync(commentDto);

            var membersToNotify = await _wallService.GetWallMembersIdsAsync(commentDto.WallId, userHubDto);

            await NotificationHub.SendWallNotificationAsync(commentDto.WallId, membersToNotify, commentDto.WallType, userHubDto);

            var postWatchers = await _postService.GetPostWatchersForAppNotificationsAsync(commentDto.PostId);

            // Comment author doesn't need to receive notification about his own comment
            postWatchers.Remove(commentDto.CommentCreator);

            // Send notification to other users
            if (postWatchers.Count > 0)
            {
                await SendNotificationAsync(commentDto, userHubDto, NotificationType.FollowingComment, postWatchers);
            }
        }