Implemented the delete function for text elements
This commit is contained in:
2 files changed
+31
-1
No files matched your search
@@ -91,4 +91,23 @@ public static class TextElementProcessor
|
||||
return updateException.ToProcessorResult<TextElement>();
|
||||
}
|
||||
}
|
||||
|
||||
// Deletes a text element:
|
||||
public static async Task DeleteTextElement(int id)
|
||||
{
|
||||
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
||||
var textElement = await db.TextElements.FirstAsync(n => n.Id == id);
|
||||
|
||||
// Remove the element from the database:
|
||||
db.TextElements.Remove(textElement);
|
||||
|
||||
try
|
||||
{
|
||||
// Save the changes:
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateException updateException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user