private static async Task UpdateAsync(BooksContext context, Book book, string user)
{
try
{
WriteLine($"{user}: updating id {book.BookId}, timestamp {book.TimeStamp.StringOutput()}");
ShowChanges(book.BookId, context.Entry(book));
int records = await context.SaveChangesAsync();
WriteLine($"{user}: updated {book.TimeStamp.StringOutput()}");
WriteLine($"{user}: {records} record(s) updated while updating {book.Title}");
}
catch (DbUpdateConcurrencyException ex)
{
WriteLine($"{user} update failed with {book.Title}");
WriteLine($"{user} error: {ex.Message}");
foreach (var entry in ex.Entries)
{
Book b = entry.Entity as Book;
WriteLine($"{b.Title} {b.TimeStamp.StringOutput()}");
ShowChanges(book.BookId, context.Entry(book));
}
}
}