From d19bb48184da00e680e3c4b277478eafe0d69906 Mon Sep 17 00:00:00 2001 From: Jiri Cincura Date: Fri, 22 Nov 2024 11:08:20 +0100 Subject: [PATCH] Use async for StudentExists. --- .../intro/samples/cu90/Pages/Students/Edit.cshtml.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aspnetcore/data/ef-rp/intro/samples/cu90/Pages/Students/Edit.cshtml.cs b/aspnetcore/data/ef-rp/intro/samples/cu90/Pages/Students/Edit.cshtml.cs index 2a9d0b299e..b436a2cb17 100644 --- a/aspnetcore/data/ef-rp/intro/samples/cu90/Pages/Students/Edit.cshtml.cs +++ b/aspnetcore/data/ef-rp/intro/samples/cu90/Pages/Students/Edit.cshtml.cs @@ -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 StudentExistsAsync(int id) { - return _context.Students.Any(e => e.ID == id); + return _context.Students.AnyAsync(e => e.ID == id); } } }