|
|
@ -18,15 +18,6 @@ namespace espacecollab.backend.appservices |
|
|
|
MapperToSqlDto = mapperToSqlDto; |
|
|
|
MapperToSqlDto = mapperToSqlDto; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//public To? Add(To apiDto) |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// T? entity = GenericRepository.Add(apiDto.ToEntity()); |
|
|
|
|
|
|
|
// if (entity == null) |
|
|
|
|
|
|
|
// return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return new To().FromEntity(entity); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<To> GetAll() |
|
|
|
public IEnumerable<To> GetAll() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return GenericRepository.GetAll().Select(entity => MapperToApiDto(entity)).ToList(); |
|
|
|
return GenericRepository.GetAll().Select(entity => MapperToApiDto(entity)).ToList(); |
|
|
@ -41,22 +32,34 @@ namespace espacecollab.backend.appservices |
|
|
|
return MapperToApiDto(entity); |
|
|
|
return MapperToApiDto(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public To? Add(To entity) |
|
|
|
public To? Add(To apiDto) |
|
|
|
{ |
|
|
|
{ |
|
|
|
T entitySql = MapperToSqlDto(entity); |
|
|
|
T sqlDto = MapperToSqlDto(apiDto); |
|
|
|
if (entitySql == null) { return null; } |
|
|
|
if (sqlDto == null) { return null; } |
|
|
|
T? entitySqlValidation = GenericRepository.Add(entitySql); |
|
|
|
T? entitySqlValidation = GenericRepository.Add(sqlDto); |
|
|
|
if (entitySqlValidation == null) { return null; } |
|
|
|
if (entitySqlValidation == null) { return null; } |
|
|
|
return MapperToApiDto(entitySqlValidation); |
|
|
|
return MapperToApiDto(entitySqlValidation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//public To? Update(To apiDto) |
|
|
|
public To? Update(To apiDto) |
|
|
|
//{ |
|
|
|
{ |
|
|
|
// T? entity = GenericRepository.Update<T>(apiDto.ToEntity()); |
|
|
|
T? sqlDto = MapperToSqlDto(apiDto); |
|
|
|
// if (entity == null) |
|
|
|
if (sqlDto == null) |
|
|
|
// return null; |
|
|
|
return null; |
|
|
|
|
|
|
|
T? sqlDtoValidation = GenericRepository.Update(sqlDto); |
|
|
|
|
|
|
|
if (sqlDtoValidation == null) { return null; } |
|
|
|
|
|
|
|
return MapperToApiDto(sqlDtoValidation); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public To? Delete(To apiDto) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
T? sqlDto = MapperToSqlDto(apiDto); |
|
|
|
|
|
|
|
if (sqlDto == null) |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
T? sqlDtoValidation = GenericRepository.Delete(sqlDto); |
|
|
|
|
|
|
|
if (sqlDtoValidation == null) { return null; } |
|
|
|
|
|
|
|
return MapperToApiDto(sqlDtoValidation); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return new To().FromEntity(entity); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|