refactor: CRUDService-Methoden auf vereinfachte Map-Methode umstellen
- `MapOrThrow` auf `Map` für das Mapping von DTOs in `CRUDService` geändert. - Methoden-Signaturen und interne Logik angepasst, um die aktualisierten `Map`-Methoden zu verwenden. - Ausnahmebehandlung und ID-Abruffunktionalität beibehalten.
This commit is contained in:
@@ -45,7 +45,7 @@ namespace DigitalData.Core.Application
|
||||
/// <returns>A service result indicating success or failure, including the entity DTO.</returns>
|
||||
public virtual async Task<DataResult<TId>> CreateAsync(TCreateDto createDto)
|
||||
{
|
||||
var entity = _mapper.MapOrThrow<TEntity>(createDto);
|
||||
var entity = _mapper.Map<TEntity>(createDto);
|
||||
var createdEntity = await _repository.CreateAsync(entity);
|
||||
return createdEntity is null ? Result.Fail<TId>() : Result.Success(KeyValueOf(createdEntity));
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace DigitalData.Core.Application
|
||||
var entity = await _repository.ReadByIdAsync(id);
|
||||
return entity is null
|
||||
? Result.Fail<TReadDto>()
|
||||
: Result.Success(_mapper.MapOrThrow<TReadDto>(entity));
|
||||
: Result.Success(_mapper.Map<TReadDto>(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,7 +70,7 @@ namespace DigitalData.Core.Application
|
||||
public virtual async Task<DataResult<IEnumerable<TReadDto>>> ReadAllAsync()
|
||||
{
|
||||
var entities = await _repository.ReadAllAsync();
|
||||
var readDto = _mapper.MapOrThrow<IEnumerable<TReadDto>>(entities);
|
||||
var readDto = _mapper.Map<IEnumerable<TReadDto>>(entities);
|
||||
return Result.Success(readDto);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user