|
|
|
@ -4,7 +4,7 @@ using espacecollab.backend.infrastructure.sql.dtos.Interfaces; |
|
|
|
|
namespace espacecollab.backend.appservices |
|
|
|
|
{ |
|
|
|
|
public abstract class GenericsServices<T, TO> where T : class, IGenericIdSqlDto |
|
|
|
|
where TO : class
|
|
|
|
|
where TO : class, IGenericIdApiDto |
|
|
|
|
{ |
|
|
|
|
Func<T, TO> MapperToApiDto { get; } |
|
|
|
|
Func<TO, T> MapperToSqlDto { get; } |
|
|
|
@ -44,9 +44,11 @@ namespace espacecollab.backend.appservices |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public TO? Update(TO apiDto) |
|
|
|
|
{ |
|
|
|
|
//TODO tester l'existence de l'apiDto dans le SQL |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
if(GetById(apiDto.Id)==null) |
|
|
|
|
{ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
T sqlDto = MapperToSqlDto(apiDto); |
|
|
|
|
T? sqlDtoValidation = GenericRepository.Update(sqlDto); |
|
|
|
|
|
|
|
|
@ -56,11 +58,9 @@ namespace espacecollab.backend.appservices |
|
|
|
|
return MapperToApiDto(sqlDtoValidation); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public bool Delete(TO apiDto) |
|
|
|
|
public bool Delete(int apiDtoId) |
|
|
|
|
{ |
|
|
|
|
T sqlDto = MapperToSqlDto(apiDto); |
|
|
|
|
|
|
|
|
|
return GenericRepository.Delete(sqlDto); |
|
|
|
|
return GenericRepository.Delete(apiDtoId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|