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:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user