diff --git a/DigitalData.Core.API/BasicCRUDControllerBase.cs b/DigitalData.Core.API/BasicCRUDControllerBase.cs index 0ce0d1e..d8feb17 100644 --- a/DigitalData.Core.API/BasicCRUDControllerBase.cs +++ b/DigitalData.Core.API/BasicCRUDControllerBase.cs @@ -7,7 +7,7 @@ namespace DigitalData.Core.API [ApiController] [Route("api/[controller]")] public class BasicCRUDControllerBase : CRUDControllerBase - where TCRUDService : ICRUDService + where TCRUDService : ICRUDService where TDto : class, IUnique where TEntity : class, IUnique { diff --git a/DigitalData.Core.API/CRUDControllerBase.cs b/DigitalData.Core.API/CRUDControllerBase.cs index 96264ba..58fe6bc 100644 --- a/DigitalData.Core.API/CRUDControllerBase.cs +++ b/DigitalData.Core.API/CRUDControllerBase.cs @@ -11,13 +11,12 @@ namespace DigitalData.Core.API /// The derived CRUD service type implementing ICRUDService. /// The Data Transfer Object type for create operations. /// The Data Transfer Object type for read operations. - /// The Data Transfer Object type for update operations. /// The entity type CRUD operations will be performed on. /// The type of the entity's identifier. [ApiController] [Route("api/[controller]")] public class CRUDControllerBase : ControllerBase - where TCRUDService : ICRUDService + where TCRUDService : ICRUDService where TCreateDto : class where TReadDto : class where TUpdateDto : class, IUnique diff --git a/DigitalData.Core.API/CRUDControllerBaseWithErrorHandling.cs b/DigitalData.Core.API/CRUDControllerBaseWithErrorHandling.cs index 168579f..644a405 100644 --- a/DigitalData.Core.API/CRUDControllerBaseWithErrorHandling.cs +++ b/DigitalData.Core.API/CRUDControllerBaseWithErrorHandling.cs @@ -12,13 +12,12 @@ namespace DigitalData.Core.API /// The derived CRUD service type implementing ICRUDService. /// The Data Transfer Object type for create operations. /// The Data Transfer Object type for read operations. - /// The Data Transfer Object type for update operations. /// The entity type CRUD operations will be performed on. /// The type of the entity's identifier. [ApiController] [Route("api/[controller]")] public class CRUDControllerBaseWithErrorHandling : ControllerBase - where TCRUDService : ICRUDService + where TCRUDService : ICRUDService where TCreateDto : class where TReadDto : class where TUpdateDto : class, IUnique diff --git a/DigitalData.Core.Abstractions/Application/IBasicCRUDService.cs b/DigitalData.Core.Abstractions/Application/IBasicCRUDService.cs index cda2c89..d967df8 100644 --- a/DigitalData.Core.Abstractions/Application/IBasicCRUDService.cs +++ b/DigitalData.Core.Abstractions/Application/IBasicCRUDService.cs @@ -15,7 +15,7 @@ namespace DigitalData.Core.Abstractions.Application /// This interface is useful for entities that do not require different DTOs for different operations, /// allowing for a more concise and maintainable codebase when implementing services for such entities. /// - public interface IBasicCRUDService : ICRUDService + public interface IBasicCRUDService : ICRUDService where TDto : class, IUnique where TEntity : class, IUnique { } diff --git a/DigitalData.Core.Abstractions/Application/ICRUDService.cs b/DigitalData.Core.Abstractions/Application/ICRUDService.cs index bffd0b2..d360b59 100644 --- a/DigitalData.Core.Abstractions/Application/ICRUDService.cs +++ b/DigitalData.Core.Abstractions/Application/ICRUDService.cs @@ -2,8 +2,8 @@ namespace DigitalData.Core.Abstractions.Application { - public interface ICRUDService : IReadService - where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class, IUnique + public interface ICRUDService : IReadService + where TCreateDto : class where TReadDto : class where TEntity : class, IUnique { /// /// Asynchronously creates a new entity based on the provided and returns the identifier of the created entity wrapped in a . @@ -20,6 +20,6 @@ namespace DigitalData.Core.Abstractions.Application /// /// The updateDTO with updated values for the entity. /// An Result indicating the outcome of the update operation, with an appropriate message. - Task UpdateAsync(TUpdateDto updateDto); + Task UpdateAsync(TUpdateDto updateDto) where TUpdateDto : IUnique; } } \ No newline at end of file diff --git a/DigitalData.Core.Application/BasicCRUDService.cs b/DigitalData.Core.Application/BasicCRUDService.cs index 93ccaec..514a3d4 100644 --- a/DigitalData.Core.Application/BasicCRUDService.cs +++ b/DigitalData.Core.Application/BasicCRUDService.cs @@ -19,7 +19,7 @@ namespace DigitalData.Core.Application /// and a culture-specific translation service for any necessary text translations, ensuring a versatile and internationalized approach to CRUD operations. /// public class BasicCRUDService : - CRUDService, IBasicCRUDService + CRUDService, IBasicCRUDService where TCRUDRepository : ICRUDRepository where TDto : class, IUnique where TEntity : class, IUnique { /// diff --git a/DigitalData.Core.Application/CRUDService.cs b/DigitalData.Core.Application/CRUDService.cs index 342c7cb..77256fc 100644 --- a/DigitalData.Core.Application/CRUDService.cs +++ b/DigitalData.Core.Application/CRUDService.cs @@ -12,11 +12,10 @@ namespace DigitalData.Core.Application /// /// The DTO type for create operations. /// The DTO type for read operations. - /// The DTO type for update operations. /// The entity type. /// The type of the identifier for the entity. - public class CRUDService : ReadService, ICRUDService - where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class where TUpdateDto : IUnique where TEntity : class, IUnique + public class CRUDService : ReadService, ICRUDService + where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class where TEntity : class, IUnique { /// @@ -45,7 +44,7 @@ namespace DigitalData.Core.Application /// /// The DTO to update an entity from. /// A service message indicating success or failure. - public virtual async Task UpdateAsync(TUpdateDto updateDto) + public virtual async Task UpdateAsync(TUpdateDto updateDto) where TUpdateDto : IUnique { var currentEntitiy = await _repository.ReadByIdAsync(updateDto.Id); diff --git a/DigitalData.Core.Application/DIExtensions.cs b/DigitalData.Core.Application/DIExtensions.cs index 3ccab86..3d8b4b5 100644 --- a/DigitalData.Core.Application/DIExtensions.cs +++ b/DigitalData.Core.Application/DIExtensions.cs @@ -40,7 +40,6 @@ namespace DigitalData.Core.Application /// The repository type that provides CRUD operations for entities of type TEntity. /// The DTO type used for create operations. /// The DTO type used for read operations. - /// The DTO type used for update operations. /// The entity type corresponding to the DTOs. /// The type of the entity's identifier. /// The AutoMapper profile type for configuring mappings between the DTOs and the entity. @@ -48,9 +47,9 @@ namespace DigitalData.Core.Application /// An optional action to configure additional services for the CRUD service. /// The original instance, allowing further configuration. public static IServiceCollection AddCleanCRUDService(this IServiceCollection services, Action? configureService = null) - where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class where TUpdateDto : class, IUnique where TEntity : class, IUnique where TProfile : Profile + where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class, IUnique where TEntity : class, IUnique where TProfile : Profile { - services.AddScoped, CRUDService>(); + services.AddScoped, CRUDService>(); configureService?.Invoke(services); services.AddAutoMapper(typeof(TProfile).Assembly);