Example #1
0
        public ServiceResult <CreateNotificationDto> Create(CreateNotificationDto create)
        {
            if (create == null)
            {
                return(new ServiceResult <CreateNotificationDto>(null));
            }


            Notification newNotification = new Notification()
            {
                Id                    = new Guid(),
                UserId                = create.UserId,
                NotificationType      = create.NotificationType,
                CreationTime          = create.CreationTime,
                Tittle                = create.Tittle,
                CreatorUserId         = create.CreatorUserId,
                EntityId              = create.EntityId,
                LastModificationTime  = create.LastModificationTime,
                LastModifierUserId    = create.LastModifierUserId,
                Read                  = false,
                TextData              = create.TextData,
                SolicitationSubsidyId = create.SolicitationSubsidyId
            };

            _contextNotification.Notifications.Add(newNotification);
            _contextNotification.SaveChanges();

            return(new ServiceResult <CreateNotificationDto>(create));
        }
        public async Task CreateAsync(CreateNotificationDto createNotificationDto)
        {
            Notification linNotification = _mapper.Map <Notification>(createNotificationDto);
            await _notificationRepository.InsertAsync(linNotification);

            _notificationRepository.UnitOfWork.Commit();
        }
        public void Post(CreateNotificationDto createNotificationDto)
        {
            Notification linNotification = _mapper.Map <Notification>(createNotificationDto);

            _notificationRepository.Insert(linNotification);
            _notificationRepository.UnitOfWork.Commit();
        }
Example #4
0
        public async Task <Guid> AddAsync(CreateNotificationDto notificationDto)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var notification = Notification.Create(notificationDto.NotificationTypeId,
                                                       notificationDto.ModuleCode, notificationDto.SenderId, notificationDto.RecipientId,
                                                       notificationDto.ObjectId, notificationDto.Url, notificationDto.Subject, notificationDto.Body,
                                                       notificationDto.AdditionalData);
                _notificationRepository.Add(notification);
                await scope.SaveChangesAsync();

                return(notification.Id);
            }
        }
Example #5
0
 public async Task CreateNotify(CreateNotificationDto input)
 {
     var notify = new Notification
     {
         OwnerId           = input.OwnerId,
         SenderId          = input.SenderId,
         OwnerType         = input.OwnerType,
         SenderType        = input.SenderType,
         Title             = input.Title,
         ContentId         = input.ContentId,
         Content           = input.Content,
         NotifyContentType = input.NotifyContentType
     };
     await _notificationRepository.AddAsync(notify);
 }
Example #6
0
        public async Task CreateNotificationAsync(CreateNotificationDto dto)
        {
            var notification = new ARNotification()
            {
                AACreatedDate                 = Clock.Now,
                ARNotificationContent         = dto.NotificationContent,
                ARNotificationObjectID        = dto.NotificationObjectId,
                ARNotificationObjectType      = dto.NotificationObjectType,
                ARNotificationRead            = false,
                ARNotificationSystemTypeCombo = NotificationSystemType.Message.ToString(),
                ARNotificationType            = dto.NotificationType,
                FK_ADUserID = dto.UserId
            };
            await _unitOfWork.GetRepository <ARNotification>().InsertAsync(notification);

            await _unitOfWork.CompleteAsync();
        }
Example #7
0
        public async Task CreateOrCancelAsync(CreateNotificationDto notificationDto)
        {
            if (notificationDto.IsCancel == false)
            {
                Notification linNotification = _mapper.Map <Notification>(notificationDto);
                await _notificationRepository.InsertAsync(linNotification);
            }
            else
            {
                Expression <Func <Notification, bool> > exprssion = r =>
                                                                    r.NotificationType == notificationDto.NotificationType &&
                                                                    r.UserInfoId == notificationDto.UserInfoId;
                switch (notificationDto.NotificationType)
                {
                case NotificationType.UserLikeArticle:    //点赞随笔
                    exprssion = exprssion.And(r => r.ArticleId == notificationDto.ArticleId);
                    break;

                case NotificationType.UserCommentOnArticle:     //评论随笔
                case NotificationType.UserLikeArticleComment:   //点赞随笔下的评论
                    exprssion = exprssion.And(r =>
                                              r.ArticleId == notificationDto.ArticleId && r.CommentId == notificationDto.CommentId);
                    break;

                case NotificationType.UserCommentOnComment:     //回复评论
                    exprssion = exprssion.And(r =>
                                              r.ArticleId == notificationDto.ArticleId && r.CommentId == notificationDto.CommentId &&
                                              r.NotificationRespUserId == notificationDto.NotificationRespUserId);
                    break;

                case NotificationType.UserLikeUser:     //关注用户
                    exprssion = exprssion.And(r =>
                                              r.NotificationRespUserId == notificationDto.NotificationRespUserId);
                    break;

                default:
                    exprssion = r => false;
                    break;
                }

                await _notificationRepository.DeleteAsync(exprssion);
            }
        }
        public CreateNotificationDto Compose(IServiceProvider services)
        {
            var userService    = services.GetService <IUserService>();
            var projectService = services.GetService <IProjectService>();

            var nullResult = new CreateNotificationDto {
            };

            return(userService.FindById(AddedByUserId).Get(
                       user => projectService.GetInfo(MemberUserId, ProjectId).Get(
                           info => new CreateNotificationDto
            {
                isLink = false,
                Link = "",
                Subject = "New project invitation",
                Message = String.Format("{0} added you to the project: {1}", user.DisplayName, info.Title)
            }, () => nullResult
                           ), () => nullResult
                       ));
        }
        private void PublishUserLikeNotification(CreateUpdateUserLikeDto createUpdateUserLike)
        {
            //根据用户点赞类型:文章、评论,得到消息的NotificationRespUserId的值
            var createNotificationDto = new CreateNotificationDto()
            {
                UserInfoId = _currentUser.Id ?? 0,
                CreateTime = DateTime.Now,
            };

            switch (createUpdateUserLike.SubjectType)
            {
            case UserLikeSubjectType.UserLikeArticle:

                Article subjectArticle = _articleAuditBaseRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOne();

                createNotificationDto.NotificationRespUserId = subjectArticle.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticle;
                createNotificationDto.ArticleId = createUpdateUserLike.SubjectId;
                break;

            case UserLikeSubjectType.UserLikeComment:

                Comment subjectComment = _commentRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOne();

                createNotificationDto.NotificationRespUserId = subjectComment.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticleComment;
                createNotificationDto.ArticleId = subjectComment.SubjectId;
                createNotificationDto.CommentId = createUpdateUserLike.SubjectId;
                break;
            }


            if (createNotificationDto.NotificationRespUserId != 0 && _currentUser.Id != createNotificationDto.NotificationRespUserId)
            {
                using ICapTransaction trans = UnitOfWork.BeginTransaction(_capBus, false);

                _capBus.Publish("NotificationController.Post", createNotificationDto);

                trans.Commit();
            }
        }
        /// <summary>
        /// 根据用户点赞类型:文章、评论,得到消息的NotificationRespUserId的值
        /// </summary>
        /// <param name="createUpdateUserLike"></param>
        /// <returns></returns>
        private async Task PublishUserLikeNotification(CreateUpdateUserLikeDto createUpdateUserLike)
        {
            var createNotificationDto = new CreateNotificationDto()
            {
                UserInfoId = _currentUser.Id ?? 0,
                CreateTime = DateTime.Now,
            };

            switch (createUpdateUserLike.SubjectType)
            {
            case UserLikeSubjectType.UserLikeArticle:

                Article subjectArticle = await _articleRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOneAsync();

                createNotificationDto.NotificationRespUserId = subjectArticle.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticle;
                createNotificationDto.ArticleId = createUpdateUserLike.SubjectId;
                break;

            case UserLikeSubjectType.UserLikeComment:

                Comment subjectComment = await _commentRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOneAsync();

                createNotificationDto.NotificationRespUserId = subjectComment.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticleComment;
                createNotificationDto.ArticleId = subjectComment.SubjectId;
                createNotificationDto.CommentId = createUpdateUserLike.SubjectId;
                break;
            }


            // if (createNotificationDto.NotificationRespUserId != 0 && _currentUser.Id != createNotificationDto.NotificationRespUserId)
            // {
            //     using ICapTransaction trans = _unitOfWorkManager.Current.BeginTransaction(_capBus, false);
            //
            //     _capBus.Publish("NotificationController.Post", createNotificationDto);
            //
            //     trans.Commit();
            // }
        }
        public static Notification ToNotification(this CreateNotificationDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            Notification entity = new Notification();

            entity.Id                 = Guid.NewGuid();
            entity.ExecutionTime      = dto.ExecutionTime.FromUnixTimeStamp();
            entity.FromDate           = dto.FromDate?.FromUnixTimeStamp();
            entity.ToDate             = dto.ToDate?.FromUnixTimeStamp();
            entity.CreatedAt          = DateTime.UtcNow;
            entity.UserId             = dto.ShrimpCropManagementFactor.Curator.Id;
            entity.WorkId             = dto.WorkId;
            entity.ManagementFactorId = dto.ManagementFactor.Id;
            entity.FarmingLocationId  = dto.FarmingLocation.Id;
            entity.ShrimpCropId       = dto.ShrimpCrop.Id;

            return(entity);
        }
        /// <summary>
        /// 根据用户点赞类型:文章、评论,得到消息的NotificationRespUserId的值
        /// </summary>
        /// <param name="createUpdateUserLike"></param>
        /// <returns></returns>
        private async Task PublishUserLikeNotification(CreateUpdateUserLikeDto createUpdateUserLike, bool isCancel)
        {
            var createNotificationDto = new CreateNotificationDto()
            {
                UserInfoId = _currentUser.Id ?? 0,
                CreateTime = DateTime.Now,
                IsCancel   = isCancel
            };

            switch (createUpdateUserLike.SubjectType)
            {
            case UserLikeSubjectType.UserLikeArticle:

                Article subjectArticle = await _articleRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOneAsync();

                createNotificationDto.NotificationRespUserId = subjectArticle.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticle;
                createNotificationDto.ArticleId = createUpdateUserLike.SubjectId;
                break;

            case UserLikeSubjectType.UserLikeComment:

                Comment subjectComment = await _commentRepository.Where(r => r.Id == createUpdateUserLike.SubjectId).ToOneAsync();

                createNotificationDto.NotificationRespUserId = subjectComment.CreateUserId;
                createNotificationDto.NotificationType       = NotificationType.UserLikeArticleComment;
                createNotificationDto.ArticleId = subjectComment.SubjectId;
                createNotificationDto.CommentId = createUpdateUserLike.SubjectId;
                break;
            }


            if (createNotificationDto.NotificationRespUserId != 0 && _currentUser.Id != createNotificationDto.NotificationRespUserId)
            {
                await _capBus.PublishAsync("NotificationController.Post", createNotificationDto);
            }
        }
Example #13
0
        public async Task <UnifyResponseDto> CreateAsync([FromBody] CreateNotificationDto createNotification)
        {
            await _notificationService.CreateAsync(createNotification);

            return(UnifyResponseDto.Success("新建消息成功"));
        }
 public UnifyResponseDto Post([FromBody] CreateNotificationDto createNotification)
 {
     _notificationService.Post(createNotification);
     return(UnifyResponseDto.Success("新建消息成功"));
 }
Example #15
0
        public async Task <IActionResult> CreateNotify(CreateNotificationDto input)
        {
            await _notificationAppService.CreateNotify(input);

            return(Ok());
        }
 public ResultDto Post([FromBody] CreateNotificationDto createNotification)
 {
     _notificationService.Post(createNotification);
     return(ResultDto.Success("新建消息成功"));
 }