using AutoMapper; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Yi.Framework.Common.Models; using Yi.Framework.Model.Base; using Yi.Framework.Repository; namespace Yi.Framework.Service.Base.Crud { public abstract class CrudAppService : CrudAppService where TEntity : class, IEntity, new() { } public abstract class CrudAppService : CrudAppService where TEntity : class, IEntity, new() { } public abstract class CrudAppService: CrudAppService where TEntity : class, IEntity, new() { protected override Task MapToGetListOutputDtoAsync(TEntity entity) { return MapToGetOutputDtoAsync(entity); } protected override TEntityDto MapToGetListOutputDto(TEntity entity) { return MapToGetOutputDto(entity); } } public abstract class CrudAppService : AbstractKeyCrudAppService where TEntity : class, IEntity, new() { protected override async Task DeleteByIdAsync(TKey id) { await DeleteAsync(new List { id }); } protected override async Task GetEntityByIdAsync(TKey id) { return await Repository.GetByIdAsync(id); } protected override void MapToEntity(TUpdateInputDto updateInput, TEntity entity) { if (updateInput is IEntityDto entityDto) { entityDto.Id = entity.Id; } base.MapToEntity(updateInput, entity); } public override async Task> DeleteAsync(IEnumerable ids) { await Repository.DeleteAsync(e => ids.Contains(e.Id)); return Result.Success(); } } }