in dotnet6/web/{{cookiecutter.project_name}}/src/ServerlessAPI/Repositories/BookRepository.cs [37:61]
public async Task<bool> DeleteAsync(Book book)
{
bool result;
try
{
// Delete the book.
await context.DeleteAsync<Book>(book.Id);
// Try to retrieve deleted book. It should return null.
Book deletedBook = await context.LoadAsync<Book>(book.Id, new DynamoDBContextConfig
{
ConsistentRead = true
});
result = deletedBook == null;
}
catch (Exception ex)
{
logger.LogError(ex, "fail to delete book from DynamoDb Table");
result = false;
}
if (result) logger.LogInformation("Book {Id} is deleted", book);
return result;
}