feat: Löschen nach E-Mail oder Signatur zur Delete-Methode und zum Service hinzugefügt

- Die `Delete`-Methode im Controller aktualisiert, um das Löschen nach `id`, `emailAddress` oder `signature` zu unterstützen.
- `DeleteByAsync`-Methode im Service hinzugefügt, um Datensätze basierend auf `emailAddress` und `signature` zu löschen.
- Fehlerbehandlung mit Protokollierung für fehlgeschlagene Löschversuche verbessert.
This commit is contained in:
Developer 02
2024-08-21 16:37:54 +02:00
parent bfe3d38ecc
commit 306956a7be
3 changed files with 38 additions and 0 deletions

View File

@@ -8,5 +8,7 @@ namespace EnvelopeGenerator.Application.Contracts
public interface IReceiverService : ICRUDService<ReceiverCreateDto, ReceiverReadDto, ReceiverUpdateDto, Receiver, int>
{
public Task<DataResult<ReceiverReadDto>> ReadByAsync(string? emailAddress = null, string? signature = null);
public Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null);
}
}

View File

@@ -26,5 +26,15 @@ namespace EnvelopeGenerator.Application.Services
return Result.Success(_mapper.MapOrThrow<ReceiverReadDto>(rcv));
}
public async Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null)
{
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
if (rcv is null)
return Result.Fail();
return await _repository.DeleteAsync(rcv) ? Result.Success() : Result.Fail();
}
}
}