refactor(repository): restructure IRepository interface with CRUD regions
- Removed AutoMapper dependency from IRepository interface. - Organized methods into Create, Read, Update, Delete (CRUD) regions. - Added CreateAsync overloads for DTOs. - Retained obsolete methods under a dedicated region.
This commit is contained in:
@@ -4,20 +4,6 @@ namespace DigitalData.Core.Abstraction.Application.Repository;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
#region Create
|
||||
public static Task<TEntity> CreateAsync<TEntity, TDto>(this IRepository<TEntity> repository, TDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var entity = repository.Mapper.Map<TEntity>(dto);
|
||||
return repository.CreateAsync(entity, ct);
|
||||
}
|
||||
|
||||
public static Task<IEnumerable<TEntity>> CreateAsync<TEntity, TDto>(this IRepository<TEntity> repository, IEnumerable<TDto> dtos, CancellationToken ct = default)
|
||||
{
|
||||
var entities = dtos.Select(dto => repository.Mapper.Map<TEntity>(dto));
|
||||
return repository.CreateAsync(entities, ct);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IRepository
|
||||
#region Read
|
||||
public static IEnumerable<TEntity> GetAll<TEntity>(this IRepository repository) where TEntity : IEntity
|
||||
|
||||
Reference in New Issue
Block a user