async calls

broken/ef
Paul Schneider 3 years ago
parent 355b2d4c7c
commit 48ca2df19e
2 changed files with 6 additions and 10 deletions

@ -124,7 +124,7 @@ namespace isn.Controllers
public async Task<IActionResult> Logout(string logoutId) public async Task<IActionResult> Logout(string logoutId)
{ {
// build a model so the logout page knows what to display // build a model so the logout page knows what to display
var vm = await BuildLogoutViewModelAsync(logoutId); var vm = BuildLogoutViewModel(logoutId);
if (vm.ShowLogoutPrompt == false) if (vm.ShowLogoutPrompt == false)
{ {
@ -144,7 +144,7 @@ namespace isn.Controllers
public async Task<IActionResult> Logout(LogoutInputModel model) public async Task<IActionResult> Logout(LogoutInputModel model)
{ {
// build a model so the logged out page knows what to display // 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) if (User?.Identity.IsAuthenticated == true)
{ {
@ -211,7 +211,7 @@ namespace isn.Controllers
return vm; return vm;
} }
private async Task<LogoutViewModel> BuildLogoutViewModelAsync(string logoutId) private LogoutViewModel BuildLogoutViewModel(string logoutId)
{ {
var vm = new LogoutViewModel { LogoutId = logoutId, ShowLogoutPrompt = AccountOptions.ShowLogoutPrompt }; var vm = new LogoutViewModel { LogoutId = logoutId, ShowLogoutPrompt = AccountOptions.ShowLogoutPrompt };
@ -227,15 +227,13 @@ namespace isn.Controllers
return vm; return vm;
} }
private async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logoutId) private LoggedOutViewModel BuildLoggedOutViewModel(string logoutId)
{ {
var vm = new LoggedOutViewModel var vm = new LoggedOutViewModel
{ {
AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut, AutomaticRedirectAfterSignOut = AccountOptions.AutomaticRedirectAfterSignOut,
LogoutId = logoutId LogoutId = logoutId
}; };
return vm; return vm;
} }

@ -39,8 +39,7 @@ namespace isn.Controllers
[HttpGet] [HttpGet]
public async Task<ActionResult> Index() public async Task<ActionResult> Index()
{ {
string userid = User.FindFirstValue(ClaimTypes.NameIdentifier); List<ApiKey> index = await GetUserKeys().ToListAsync();
System.Collections.Generic.List<ApiKey> index = GetUserKeys().ToList();
IndexModel model = new IndexModel { ApiKey = index }; IndexModel model = new IndexModel { ApiKey = index };
ViewData["Title"] = "Index"; ViewData["Title"] = "Index";
return View("Index", model); return View("Index", model);
@ -50,7 +49,6 @@ namespace isn.Controllers
public async Task<ActionResult> Create() public async Task<ActionResult> Create()
{ {
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var username = User.Identity.Name;
var user = await _userManager.FindByIdAsync(userId); var user = await _userManager.FindByIdAsync(userId);
ViewBag.UserId = new SelectList(new List<ApplicationUser> { user }); ViewBag.UserId = new SelectList(new List<ApplicationUser> { user });
return View(new CreateModel{ }); return View(new CreateModel{ });
@ -79,7 +77,7 @@ namespace isn.Controllers
public async Task<ActionResult> Delete(string id) public async Task<ActionResult> Delete(string id)
{ {
string userid = User.FindFirstValue(ClaimTypes.NameIdentifier); 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 }); return View(new DeleteModel { ApiKey = key });
} }

Loading…