Skip to content

Commit d19bb48

Browse files
committed
Use async for StudentExists.
1 parent e83f4ac commit d19bb48

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

aspnetcore/data/ef-rp/intro/samples/cu90/Pages/Students/Edit.cshtml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
@@ -56,7 +56,7 @@ public async Task<IActionResult> OnPostAsync()
5656
}
5757
catch (DbUpdateConcurrencyException)
5858
{
59-
if (!StudentExists(Student.ID))
59+
if (!await StudentExistsAsync(Student.ID))
6060
{
6161
return NotFound();
6262
}
@@ -69,9 +69,9 @@ public async Task<IActionResult> OnPostAsync()
6969
return RedirectToPage("./Index");
7070
}
7171

72-
private bool StudentExists(int id)
72+
private Task<bool> StudentExistsAsync(int id)
7373
{
74-
return _context.Students.Any(e => e.ID == id);
74+
return _context.Students.AnyAsync(e => e.ID == id);
7575
}
7676
}
7777
}

0 commit comments

Comments
 (0)