feat: ReadService hinzugefügt und in ReadController integriert

- Generischen ReadService erstellt, um Lese- (ReadById, ReadAll) und Löschoperationen zu verwalten.
- ReadService in den ReadController integriert.
This commit is contained in:
Developer 02
2024-09-16 09:08:27 +02:00
parent 2c739fbf02
commit 993d407a48
8 changed files with 97 additions and 91 deletions

View File

@@ -1,23 +0,0 @@
using AutoMapper;
namespace DigitalData.Core.DTO
{
public static class AutoMapperExtension
{
[Obsolete("use mapper.Map<T>")]
/// <summary>
/// Maps a source object to a destination object, or throws an exception if the mapping result is null.
/// </summary>
/// <typeparam name="TSource">The source object type.</typeparam>
/// <typeparam name="TDestination">The destination object type.</typeparam>
/// <param name="source">The source object to map from.</param>
/// <returns>The mapped destination object.</returns>
/// <exception cref="MappingResultNullException">Thrown when the mapping result is null.</exception>
public static TDestination MapOrThrow<TDestination>(this IMapper mapper, object source)
{
return mapper.Map<TDestination>(source) ?? throw new AutoMapperMappingException(
$"Mapping to {typeof(TDestination).FullName} resulted in a null object. " +
"Hint: Ensure that the AutoMapper profile configuration for this mapping is correct.");
}
}
}