Exemplo n.º 1
0
        public async Task <List <NotificationSubscriptionDto> > GetNotificationSubscriptionDtosAsync()
        {
            var list = await _notificationSubscriptionManager.GetSubscribedNotificationsAsync(LoginIdentifier);

            return(list.Select(x => new NotificationSubscriptionDto
            {
                UserId = x.UserId,
                NotificationName = x.NotificationName,
                CreationTime = x.CreationTime
            }).ToList());
        }
Exemplo n.º 2
0
        public async Task <ListResultDto <NotificationSubscriptionDto> > GetSubscribedAsync()
        {
            var result = await _subscriptionManager.GetSubscribedNotificationsAsync(CurrentUser.Id.Value);

            var dto = ObjectMapper.Map <List <NotificationSubscriptionInfo>, List <NotificationSubscriptionDto> >(result);

            foreach (var subscription in dto)
            {
                var notificationDefinition = _notificationDefinitionManager.Get(subscription.NotificationName);
                subscription.DisplayName = notificationDefinition.DisplayName.Localize(StringLocalizerFactory);
                subscription.Description = notificationDefinition.Description.Localize(StringLocalizerFactory);
            }

            return(new ListResultDto <NotificationSubscriptionDto>(dto));
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        public async Task <GetNotificationSettingsOutput> GetNotificationSettings()
        {
            var output = new GetNotificationSettingsOutput
            {
                ReceiveNotifications =
                    await SettingManager.GetSettingValueAsync <bool>(NotificationSettingNames.ReceiveNotifications),
                Notifications = (await _notificationDefinitionManager
                                 .GetAllAvailableAsync(AbpSession.ToUserIdentifier()))
                                .Where(nd => nd.EntityType == null) //Get general notifications, not entity related notifications.
                                .MapTo <List <NotificationSubscriptionWithDisplayNameDto> >()
            };
            var subscribedNotifications = (await _notificationSubscriptionManager
                                           .GetSubscribedNotificationsAsync(AbpSession.ToUserIdentifier()))
                                          .Select(ns => ns.NotificationName)
                                          .ToList();

            output.Notifications.ForEach(n => n.IsSubscribed = subscribedNotifications.Contains(n.Name));
            return(output);
        }
 /// <summary>
 /// Gets subscribed notifications for a user.
 /// </summary>
 /// <param name="notificationSubscriptionManager">Notification subscription manager</param>
 /// <param name="user">User.</param>
 public static List <NotificationSubscription> GetSubscribedNotifications(this INotificationSubscriptionManager notificationSubscriptionManager, UserIdentifier user)
 {
     return(AsyncHelper.RunSync(() => notificationSubscriptionManager.GetSubscribedNotificationsAsync(user)));
 }
 /// <summary>
 /// Gets subscribed notifications for a user.
 /// </summary>
 public static List <NotificationSubscriptionDto> GetSubscribedNotifications(this INotificationSubscriptionManager notificationSubscriptionManager, long userId)
 {
     return(AsyncHelper.RunSync(() => notificationSubscriptionManager.GetSubscribedNotificationsAsync(userId)));
 }