update institucion programa listo
This commit is contained in:
@@ -47,6 +47,16 @@ export class InstitucionProgramaService {
|
||||
return this.programaRepository.find();
|
||||
}
|
||||
|
||||
findById(id_institucion_programa: number) {
|
||||
return this.institucionProgramaRepository
|
||||
.findOne({ id_institucion_programa })
|
||||
.then((institucionPrograma) => {
|
||||
if (!institucionPrograma)
|
||||
throw new NotFoundException('No existe esta institucion programa.');
|
||||
return institucionPrograma;
|
||||
});
|
||||
}
|
||||
|
||||
findProgramaById(id_programa: number) {
|
||||
return this.programaRepository.findOne({ id_programa }).then((programa) => {
|
||||
if (!programa) throw new NotFoundException('No existe este programa.');
|
||||
@@ -77,4 +87,16 @@ export class InstitucionProgramaService {
|
||||
this.institucionProgramaRepository.find({ institucion, mostrar: true }),
|
||||
);
|
||||
}
|
||||
|
||||
update(attrs: Partial<InstitucionPrograma>) {
|
||||
return this.findById(attrs.id_institucion_programa)
|
||||
.then((institucionPrograma) => {
|
||||
Object.assign(institucionPrograma, attrs);
|
||||
return this.institucionProgramaRepository.save(institucionPrograma);
|
||||
})
|
||||
.then((_) => ({
|
||||
message:
|
||||
'Se actualizó correctamente la información de esta institución programa.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user