Use async for StudentExists.

pull/34203/head
Jiri Cincura 2024-11-22 11:08:20 +01:00
parent e83f4acd6d
commit d19bb48184
No known key found for this signature in database
1 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -56,7 +56,7 @@ namespace ContosoUniversity.Pages.Students
}
catch (DbUpdateConcurrencyException)
{
if (!StudentExists(Student.ID))
if (!await StudentExistsAsync(Student.ID))
{
return NotFound();
}
@ -69,9 +69,9 @@ namespace ContosoUniversity.Pages.Students
return RedirectToPage("./Index");
}
private bool StudentExists(int id)
private Task<bool> StudentExistsAsync(int id)
{
return _context.Students.Any(e => e.ID == id);
return _context.Students.AnyAsync(e => e.ID == id);
}
}
}