コード例 #1
0
        public async Task <List <UserNotificationDto> > GetUserNotificationsAsync()
        {
            var definitions = _notificationDefinitionManager.GetAll();

            //var notificationDescription = definitions.Any(x=>x.Name == )
            string GetDescription(string notificationName)
            {
                return(definitions.FirstOrDefault(x => x.Name == notificationName)?.DisplayName.Localize(_localizationContext) ?? notificationName);
            }

            var models = await _userNotificationManager.GetUserNotificationsAsync(LoginIdentifier, null);

            var list = models.Select(x => new UserNotificationDto
            {
                Id               = x.Id,
                State            = x.State,
                NotificationName = x.Notification.NotificationName,
                Description      = GetDescription(x.Notification.NotificationName),
                Severity         = x.Notification.Severity,
                CreationTime     = x.Notification.CreationTime,
                EntityId         = x.Notification.EntityId,
                EntityTypeName   = x.Notification.EntityTypeName
            }).ToList();

            return(list);
        }