Add example delete for coach.
This commit is contained in:
parent
f58ce8f120
commit
86b2e60e8c
@ -13,6 +13,17 @@ using var context = new DeadBallZoneLeagueDbContext();
|
||||
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
|
||||
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
|
||||
|
||||
async Task DeleteCoach(int id)
|
||||
{
|
||||
var coach = await context.Coaches.FindAsync(id);
|
||||
if (coach != null)
|
||||
{
|
||||
context.Remove(coach);
|
||||
// context.Entry(coach).State = EntityState.Deleted;
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
async Task UpdateCoach()
|
||||
{
|
||||
var coach = await context.Coaches.FindAsync(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user