Use async for StudentExists.
parent
e83f4acd6d
commit
d19bb48184
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -56,7 +56,7 @@ namespace ContosoUniversity.Pages.Students
|
||||||
}
|
}
|
||||||
catch (DbUpdateConcurrencyException)
|
catch (DbUpdateConcurrencyException)
|
||||||
{
|
{
|
||||||
if (!StudentExists(Student.ID))
|
if (!await StudentExistsAsync(Student.ID))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ namespace ContosoUniversity.Pages.Students
|
||||||
return RedirectToPage("./Index");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue