示例#1
0
        public async Task <bool> CommentNotification(CommentNotification commentNotification)
        {
            Logger.LogInformation($"{nameof(NotificationsMessageService)}.{nameof(CommentNotification)}.Start");
            var info = await Db.UsersInfo.FindUserInfoAsync(commentNotification.NotifierId);

            if (info == null)
            {
                return(false);
            }
            var sendToId = await Db.Notifications.GetUserIdForComment(commentNotification.CommentId);

            if (sendToId <= 0)
            {
                return(false);
            }

            var notification = new Notification
            {
                UserId          = commentNotification.NotifierId,
                Login           = info.FirstName + " " + info.LastName,
                SmallAvatarLink = MediaConverter.ToFullAvatarUrl(info.OriginalAvatarUrl, AvatarSizeType.Small),
                ActionType      = ActionType.Follow,
                EmmiterId       = commentNotification.CommentId,
                ActionDate      = commentNotification.CommentedDate
            };

            await PushNotification(sendToId, notification);

            Logger.LogInformation($"{nameof(NotificationsMessageService)}.{nameof(CommentNotification)}.End");
            return(true);
        }
        // POST: CommentNotifications/Delete/5
        public ActionResult DeleteConfirmed(int id)
        {
            CommentNotification commentNotification = db.CommentNotifications.Find(id);

            db.CommentNotifications.Remove(commentNotification);
            db.SaveChanges();
            return(RedirectToAction("UserPortal", "Manage", null));
        }
        public void TriggerCommentNotification(Comment comment, ApplicationDbContext db)
        {
            CommentNotification commentNotification = new CommentNotification();

            commentNotification.CommentId    = comment.Id;
            commentNotification.AspNetUserId = GetCommentArticleAuthorId(comment.ArticleId, db);

            db.CommentNotifications.Add(commentNotification);
            db.SaveChanges();
        }
示例#4
0
        public async Task <IActionResult> NotifyComment([FromBody] CommentNotification notification)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }

            await _notificationsMessageHandler.CommentNotification(notification);

            return(new OkResponseResult());
        }
 public async void commentByAnchoredUserIdsAsync(List <int> userIds, string actionUserName, int masterPatientID, int discrepancyID, int discrepancyCommentID)
 {
     foreach (int userId in userIds)
     {
         var commentNotification = new CommentNotification()
         {
             MasterPatientID      = masterPatientID,
             DiscrepancyID        = discrepancyID,
             DiscrepancyCommentID = discrepancyCommentID
         };
         await Task.Run(() => commentByAnchoredUserIdAsync(userId, actionUserName, commentNotification));
     }
 }
示例#6
0
 internal CommentNotificationCallback(CMsgClientCommentNotifications msg)
 {
     CommentNotifications = new CommentNotification(msg);
 }
示例#7
0
 internal CommentNotificationCallback(CMsgClientCommentNotifications msg)
 {
     CommentNotifications = new CommentNotification(msg);
 }
        public async void commentByAnchoredUserIdAsync(int userId, string actionUserName, CommentNotification commentNotification)
        {
            NotificationDto notification = new NotificationDto()
            {
                AnchoredUserID   = userId,
                ActionUserName   = actionUserName,
                NotificationType = NotificationTypes.COMMENT,
                EntryTime        = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"),
                NotificationStr  = JsonConvert.SerializeObject(commentNotification)
            };

            await Task.Run(() => _notificationService.AddNotificationByIdAsync(userId, notification));

            sendNotificationById(userId, notification);
        }