public async Task <NotificationOutput> GetMyNotifications(int rowsPerPage, int?page, string search)
        {
            if (AbpSession.UserId == null)
            {
                return(new NotificationOutput());
            }
            var notifications = await _userNotificationManager.GetUserNotificationsAsync(new UserIdentifier(AbpSession.TenantId, AbpSession.UserId.Value));

            if (!string.IsNullOrEmpty(search))
            {
                notifications = notifications.Where(a => a.Notification.Data.ToString().Contains(search)).ToList();
            }

            return(new NotificationOutput()
            {
                Notifications = notifications.Select(a => a.MapTo <NotificationDto>()).ToList()
            });
        }
Esempio n. 2
0
        public async Task <ActionResult> Index()
        {
            var userId        = new UserIdentifier(AbpSession.TenantId, AbpSession.GetUserId());
            var notifications = (await _notificationManager.GetUserNotificationsAsync(userId))
                                .GroupBy(n => n.Notification.Data["Message"])
                                // reduce all same notifications
                                .Select(ng =>
            {
                var newNg = ng
                            .Where(n => n.State == UserNotificationState.Unread)
                            .OrderByDescending(n => n.Notification.CreationTime)
                            .ToList();
                return(new Pair <long, UserNotification>(newNg.Count, newNg.FirstOrDefault() ?? ng.First()));
            })
                                .OrderByDescending(p => p.Second.Notification.CreationTime)
                                .ToList();

            return(View(notifications));
        }
Esempio n. 3
0
        public async Task <NotificationsOutput> GetMyNotifications(UserNotificationState state, int?take = null)
        {
            if (AbpSession.UserId == null)
            {
                return(new NotificationsOutput());
            }
            var userIdentifier = new UserIdentifier(AbpSession.TenantId,
                                                    AbpSession.UserId.Value);
            var notifications = (await _userNotificationManager.GetUserNotificationsAsync(userIdentifier));

            notifications.AddRange((await _userNotificationManager.GetUserNotificationsAsync(userIdentifier, UserNotificationState.Read)));

            if (take.HasValue)
            {
                notifications = notifications.Take(take.Value).ToList();
            }
            return(new NotificationsOutput()
            {
                Notifications = notifications.ToList()
            });
        }
Esempio n. 4
0
        public async Task <NotificationOutput> GetMyNotifications(int rowsPerPage, int?page, string search)
        {
            if (AbpSession.UserId == null)
            {
                return(new NotificationOutput());
            }
            var notifications = await _userNotificationManager.GetUserNotificationsAsync(new UserIdentifier(AbpSession.TenantId, AbpSession.UserId.Value));

            return(new NotificationOutput()
            {
                Notifications = notifications.Select(a => a.MapTo <NotificationDto>()).ToList()
            });
        }