public async Task <SearchResult <NotificationDetailsResult> > Handle(SearchNotificationsQuery request, CancellationToken cancellationToken)
        {
            if (request.Claims == null || !request.Claims.Any())
            {
                _logger.LogError("User is not authenticated");
                throw new NotAuthenticatedException(Global.UserNotAuthenticated);
            }

            var userClaims = new UserClaims
            {
                UserIdentifier = _authorizationHelper.GetNameIdentifier(request.Claims),
                Roles          = _authorizationHelper.GetRoles(request.Claims),
                LogicalGroups  = (await _logicalPeopleGroupStore.GetLogicalGroups(request.Claims, cancellationToken)).Select(_ => _.Name).ToList()
            };
            var result = await _notificationInstanceQueryRepository.Find(new FindNotificationInstanceParameter
            {
                Count      = request.Count,
                Order      = request.Order,
                OrderBy    = request.OrderBy,
                StartIndex = request.StartIndex,
                User       = userClaims
            }, cancellationToken);

            var content = new List <NotificationDetailsResult>();

            foreach (var record in result.Content)
            {
                var callbackTxt = new Func <ICollection <PresentationElementInstance>, Localization.Translation>((t) =>
                {
                    if (t == null || !t.Any())
                    {
                        return(null);
                    }

                    try
                    {
                        return(_translationHelper.Translate(t));
                    }
                    catch (BadOperationExceptions) { return(null); }
                });
                var name    = callbackTxt(record.Names);
                var subject = callbackTxt(record.Subjects);
                content.Add(NotificationDetailsResult.ToDto(record, name, subject));
            }

            return(new SearchResult <NotificationDetailsResult>
            {
                StartIndex = result.StartIndex,
                TotalLength = result.TotalLength,
                Count = result.Count,
                Content = content
            });
        }
        public async Task <SearchResult <TaskInstanceDetailsResult> > Handle(SearchHumanTaskInstanceDetailsQuery request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Search human task instance");
            var nameIdentifier = _authorizationHelper.GetNameIdentifier(request.Claims);
            var roles          = _authorizationHelper.GetRoles(request.Claims);
            var result         = await _humanTaskInstanceQueryRepository.Search(new SearchHumanTaskInstanceParameter
            {
                UserIdentifier = nameIdentifier,
                GroupNames     = roles,
                Count          = request.Count,
                Order          = request.Order,
                OrderBy        = request.OrderBy,
                StartIndex     = request.StartIndex,
                StatusLst      = request.StatusLst,
                ActualOwner    = request.ActualOwner
            }, cancellationToken);

            var content = new List <TaskInstanceDetailsResult>();

            foreach (var record in result.Content)
            {
                var callbackTxt = new Func <ICollection <PresentationElementInstance>, Localization.Translation>((t) =>
                {
                    if (t == null || !t.Any())
                    {
                        return(null);
                    }

                    try
                    {
                        return(_translationHelper.Translate(t));
                    }
                    catch (BadOperationExceptions) { return(null); }
                });
                var appRoles = await _authorizationHelper.GetRoles(record, request.Claims, cancellationToken);

                var name    = callbackTxt(record.Names);
                var subject = callbackTxt(record.Subjects);
                content.Add(TaskInstanceDetailsResult.ToDto(record, name, subject, appRoles, _authorizationHelper.GetNameIdentifier(request.Claims)));
            }

            return(new SearchResult <TaskInstanceDetailsResult>
            {
                Count = result.Count,
                TotalLength = result.TotalLength,
                StartIndex = result.StartIndex,
                Content = content
            });
        }