Beispiel #1
0
        private async Task <PagedResult <Process> > ExecuteSearch(int offset, int limit, IDictionary <object, object> context, string query, DynamicParameters parameters, CancellationToken cancellationToken)
        {
            var policy = _connectionFactory.PolicySelector(_logger);

            var result = await policy.ExecuteAsync(async() =>
            {
                using (var connection = _connectionFactory.Create("raa"))
                {
                    int count = await GetProcessCountAsync(BuildCountQuery(query), parameters, connection, cancellationToken, context);

                    IDictionary <int, Process> processList = await GetProcessList(BuildResultSetQuery(query), parameters, offset, limit, connection, cancellationToken, context);

                    foreach (var processId in processList.Keys)
                    {
                        var process = processList[processId];

                        PersonIdentification org    = await _personIdentificationStore.GetByIdAsync(process.OriginatorId);
                        process.OriginatorHanfordId = org.HanfordId;

                        PersonIdentification beni    = await _personIdentificationStore.GetByIdAsync(process.BeneficiaryId);
                        process.BeneficiaryHanfordId = beni.HanfordId;

                        foreach (var activity in process.Activities)
                        {
                            if (!string.IsNullOrEmpty(activity.Value.ActedUserId))
                            {
                                PersonIdentification act      = await _personIdentificationStore.GetByIdAsync(activity.Value.ActedUserId);
                                activity.Value.ActedHanfordId = act.HanfordId;
                            }
                        }
                    }

                    return(new PagedResult <Process>(offset, limit, count, processList.Values.ToList()));
                }
            });

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> GetByIdAsync(string id)
        {
            try
            {
                var result = await _personIdtore.GetByIdAsync(id, HttpContext.RequestAborted, HttpContext.Items);

                if (result == null)
                {
                    return(NotFound(result));
                }

                return(Ok(result));
            }
            catch (ArgumentException exception)
            {
                return(BadRequest(exception.Message));
            }
            catch (Exception exception)
            {
                _logger.LogError($"{HttpContext.TraceIdentifier} Unable to retrieve status. Reason: {exception}");
                throw;
            }
        }