Beispiel #1
0
        public static async Task <HttpResponseMessage> SessionManagement(
            [OptionalQueryParameter(Name = "ApiKeySecurity")] string apiSecurityKey,
            ApiSecurity apiSecurity,
            EastFive.Api.Azure.AzureApplication application,
            UnauthorizedResponse onUnauthorized,
            ViewFileResponse viewResponse)
        {
            return(await await CredentialProcessDocument.FindAllAsync(
                       async documents =>
            {
                var orderedDocs = documents.OrderByDescending(doc => doc.Time).Take(1000).ToArray();

                var details = new SessionManagementDetails()
                {
                };
                details.CredentialDocuments = orderedDocs;
                details.AccountIdToNameLookup = await orderedDocs
                                                .Select(doc => doc.AuthorizationId)
                                                .Distinct()
                                                .Select(
                    async authId =>
                {
                    var fullName = await application.GetActorNameDetailsAsync(authId,
                                                                              (username, firstName, lastName) =>
                    {
                        return $"{firstName} {lastName}";
                    },
                                                                              () => string.Empty);
                    return fullName.PairWithKey(authId);
                })
                                                .AsyncEnumerable()
                                                .ToDictionaryAsync();

                return viewResponse("/SessionManagement/Index.cshtml", details);
            },
                       BlackBarLabs.Persistence.Azure.StorageTables.AzureStorageRepository.CreateRepository(
                           EastFive.Azure.AppSettings.ASTConnectionStringKey)));
        }