Refactor: Erzwinge IUnique<TId> Einschränkung für TUpdateDto in CRUDService

- Aktualisiert: `ICRUDService` und `CRUDService`, um die `IUnique<TId>`-Einschränkung für `TUpdateDto` sicherzustellen, dass Update-Datenübertragungsobjekte eine eindeutige Kennung enthalten.
This commit is contained in:
Developer 02 2024-09-11 09:29:21 +02:00
parent 5f18ccd2bd
commit d59350174c
2 changed files with 3 additions and 2 deletions

View File

@ -4,7 +4,7 @@ using DigitalData.Core.DTO;
namespace DigitalData.Core.Abstractions.Application namespace DigitalData.Core.Abstractions.Application
{ {
public interface ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId> public interface ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
where TCreateDto : class where TReadDto : class where TUpdateDto : class where TEntity : class where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class
{ {
Task<DataResult<TId>> CreateAsync(TCreateDto createDto); Task<DataResult<TId>> CreateAsync(TCreateDto createDto);

View File

@ -4,6 +4,7 @@ using AutoMapper;
using System.Reflection; using System.Reflection;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using DigitalData.Core.DTO; using DigitalData.Core.DTO;
using DigitalData.Core.Abstractions;
namespace DigitalData.Core.Application namespace DigitalData.Core.Application
{ {
@ -16,7 +17,7 @@ namespace DigitalData.Core.Application
/// <typeparam name="TEntity">The entity type.</typeparam> /// <typeparam name="TEntity">The entity type.</typeparam>
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam> /// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
public class CRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId> public class CRUDService<TCRUDRepository, TCreateDto, TReadDto, TUpdateDto, TEntity, TId> : ICRUDService<TCreateDto, TReadDto, TUpdateDto, TEntity, TId>
where TCRUDRepository : ICRUDRepository<TEntity, TId> where TCreateDto : class where TReadDto : class where TUpdateDto : class where TEntity : class where TCRUDRepository : ICRUDRepository<TEntity, TId> where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique<TId> where TEntity : class
{ {
protected readonly TCRUDRepository _repository; protected readonly TCRUDRepository _repository;
protected readonly IMapper _mapper; protected readonly IMapper _mapper;