36 lines
2.5 KiB
C#
36 lines
2.5 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Contracts.CleanArchitecture.Application;
|
|
using DigitalData.Core.Contracts.CleanArchitecture.Infrastructure;
|
|
using DigitalData.Core.Contracts.CultureServices;
|
|
|
|
namespace DigitalData.Core.CleanArchitecture.Application
|
|
{
|
|
/// <summary>
|
|
/// Provides a concrete implementation of a basic CRUD service that uses a single Data Transfer Object (DTO) for all CRUD operations.
|
|
/// This service simplifies the management of entities by utilizing a consistent object model throughout create, read, update, and delete operations.
|
|
/// It extends the generic CRUDService by specifying the same DTO type for all generic parameters, facilitating a straightforward mapping between the entity and its data transfer representation.
|
|
/// </summary>
|
|
/// <typeparam name="TDto">The Data Transfer Object type used for all operations.</typeparam>
|
|
/// <typeparam name="TEntity">The entity type being managed by this service.</typeparam>
|
|
/// <typeparam name="TId">The type of the identifier for the entity.</typeparam>
|
|
/// <remarks>
|
|
/// This service is ideal for scenarios where a single DTO is adequate to represent the entity in all operations,
|
|
/// reducing the need for multiple DTOs and simplifying the data mapping process. It leverages AutoMapper for object mapping
|
|
/// and a culture-specific translation service for any necessary text translations, ensuring a versatile and internationalized approach to CRUD operations.
|
|
/// </remarks>
|
|
public class BasicCRUDService<TCRUDRepository, TDto, TEntity, TId> :
|
|
CRUDService<TCRUDRepository, TDto, TDto, TDto, TEntity, TId>, IBasicCRUDService<TCRUDRepository, TDto, TEntity, TId>
|
|
where TCRUDRepository : ICRUDRepository<TEntity, TId> where TDto : class where TEntity : class
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the BasicCRUDService with the specified repository, translation service, and AutoMapper configuration.
|
|
/// </summary>
|
|
/// <param name="repository">The CRUD repository for accessing and manipulating entity data.</param>
|
|
/// <param name="translationService">The service used for key-based text translations, facilitating localization.</param>
|
|
/// <param name="mapper">The AutoMapper instance for mapping between DTOs and entities.</param>
|
|
public BasicCRUDService(TCRUDRepository repository, IKeyTranslationService translationService, IMapper mapper) :
|
|
base(repository, translationService, mapper)
|
|
{
|
|
}
|
|
}
|
|
} |