public async Task SubscribeToAllAvailableNotificationsAsync(UserIdentifier user) { var notificationDefinitions = (await _notificationDefinitionManager .GetAllAvailableAsync(user)) .Where(nd => nd.EntityType == null) .ToList(); foreach (var notificationDefinition in notificationDefinitions) { await SubscribeAsync(user, notificationDefinition.Name); } }
public async Task SubscribeToAllAvailableNotificationsAsync(int?tenantId, long userId) { var notificationDefinitions = (await _notificationDefinitionManager .GetAllAvailableAsync(tenantId, userId)) .Where(nd => nd.EntityType == null) .ToList(); foreach (var notificationDefinition in notificationDefinitions) { await SubscribeAsync(tenantId, userId, notificationDefinition.Name); } }
public async Task <List <NotificationDefinitionDto> > GetAllAvailableAsync() { var subscribes = (await _notificationSubscriptionManager.GetSubscribedNotificationsAsync(LoginIdentifier)) .Where(x => x.EntityType == null).ToList(); bool IsSubscribed(NotificationDefinition definition) { return(subscribes.Any(x => x.NotificationName == definition.Name)); } var list = await _notificationDefinitionManager.GetAllAvailableAsync(LoginIdentifier); return(list.Select(x => new NotificationDefinitionDto { Name = x.Name, Description = x.DisplayName.Localize(_localizationContext), IsSubscribed = IsSubscribed(x) }).ToList()); }
/// <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 all available notification definitions for given user. /// </summary> /// <param name="notificationDefinitionManager">Notification definition manager</param> /// <param name="user">User</param> public static IReadOnlyList <NotificationDefinition> GetAllAvailable(this INotificationDefinitionManager notificationDefinitionManager, UserIdentifier user) { return(AsyncHelper.RunSync(() => notificationDefinitionManager.GetAllAvailableAsync(user))); }
/// <summary> /// Gets all available notification definitions for given <see cref="tenantId"/> and <see cref="userId"/>. /// </summary> /// <param name="notificationDefinitionManager">Notification definition manager</param> /// <param name="tenantId">Tenant id</param> /// <param name="userId">User id</param> public static IReadOnlyList <NotificationDefinition> GetAllAvailable(this INotificationDefinitionManager notificationDefinitionManager, int?tenantId, long userId) { return(AsyncHelper.RunSync(() => notificationDefinitionManager.GetAllAvailableAsync(tenantId, userId))); }