From 48ca2df19ea95b331eefacb9dcf74fd0d72e3916 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 11 Jul 2021 18:09:02 +0100 Subject: [PATCH] async calls --- src/isnd/Controllers/AccountController.cs | 10 ++++------ src/isnd/Controllers/ApiKeysController.cs | 6 ++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/isnd/Controllers/AccountController.cs b/src/isnd/Controllers/AccountController.cs index 51109b6..c0f920e 100644 --- a/src/isnd/Controllers/AccountController.cs +++ b/src/isnd/Controllers/AccountController.cs @@ -124,7 +124,7 @@ namespace isn.Controllers public async Task Logout(string logoutId) { // build a model so the logout page knows what to display - var vm = await BuildLogoutViewModelAsync(logoutId); + var vm = BuildLogoutViewModel(logoutId); if (vm.ShowLogoutPrompt == false) { @@ -144,7 +144,7 @@ namespace isn.Controllers public async Task Logout(LogoutInputModel model) { // build a model so the logged out page knows what to display - var vm = await BuildLoggedOutViewModelAsync(model.LogoutId); + var vm = BuildLoggedOutViewModel(model.LogoutId); if (User?.Identity.IsAuthenticated == true) { @@ -211,7 +211,7 @@ namespace isn.Controllers return vm; } - private async Task BuildLogoutViewModelAsync(string logoutId) + private LogoutViewModel BuildLogoutViewModel(string logoutId) { var vm = new LogoutViewModel { LogoutId = logoutId, ShowLogoutPrompt = AccountOptions.ShowLogoutPrompt }; @@ -227,15 +227,13 @@ namespace isn.Controllers return vm; } - private async Task BuildLoggedOutViewModelAsync(string logoutId) + private LoggedOutViewModel BuildLoggedOutViewModel(string logoutId) { - var vm = new LoggedOutViewModel { AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut, LogoutId = logoutId }; - return vm; } diff --git a/src/isnd/Controllers/ApiKeysController.cs b/src/isnd/Controllers/ApiKeysController.cs index 5000fa7..9a28997 100644 --- a/src/isnd/Controllers/ApiKeysController.cs +++ b/src/isnd/Controllers/ApiKeysController.cs @@ -39,8 +39,7 @@ namespace isn.Controllers [HttpGet] public async Task Index() { - string userid = User.FindFirstValue(ClaimTypes.NameIdentifier); - System.Collections.Generic.List index = GetUserKeys().ToList(); + List index = await GetUserKeys().ToListAsync(); IndexModel model = new IndexModel { ApiKey = index }; ViewData["Title"] = "Index"; return View("Index", model); @@ -50,7 +49,6 @@ namespace isn.Controllers public async Task Create() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); - var username = User.Identity.Name; var user = await _userManager.FindByIdAsync(userId); ViewBag.UserId = new SelectList(new List { user }); return View(new CreateModel{ }); @@ -79,7 +77,7 @@ namespace isn.Controllers public async Task Delete(string id) { string userid = User.FindFirstValue(ClaimTypes.NameIdentifier); - ApiKey key = dbContext.ApiKeys.FirstOrDefault(k => k.Id == id && k.UserId == userid); + ApiKey key = await dbContext.ApiKeys.FirstOrDefaultAsync(k => k.Id == id && k.UserId == userid); return View(new DeleteModel { ApiKey = key }); }