Use ExecuteDelete instead of ffetching data and then removing the entries

This commit is contained in:
2025-09-24 17:43:47 +02:00
parent 7954c4b72e
commit fc7b832926
8 changed files with 15 additions and 29 deletions

View File

@@ -163,11 +163,9 @@ public class NotificationConnectorController(NotificationsContext context) : Con
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public async Task<Results<Ok, NotFound<string>, InternalServerError<string>>> DeleteConnector (string Name)
{
if (await context.NotificationConnectors.FirstOrDefaultAsync(c => c.Name == Name, HttpContext.RequestAborted) is not { } connector)
if (await context.NotificationConnectors.Where(c => c.Name == Name).ExecuteDeleteAsync(HttpContext.RequestAborted) < 1)
return TypedResults.NotFound(nameof(Name));
context.NotificationConnectors.Remove(connector);
if(await context.Sync(HttpContext.RequestAborted, GetType(), System.Reflection.MethodBase.GetCurrentMethod()?.Name) is { success: false } result)
return TypedResults.InternalServerError(result.exceptionMessage);
return TypedResults.Ok();