POSTprograms
This commit is contained in:
@@ -15,19 +15,22 @@ export class ProgramaService {
|
||||
findAll() {
|
||||
return this.programaRepository.find({order:{programa:'ASC'}});
|
||||
}
|
||||
|
||||
findOne(id_programa: number) {
|
||||
const programa = this.programaRepository.findOne({where:{id_programa}})
|
||||
|
||||
if(!programa){
|
||||
return "this program dosnt exist"
|
||||
}
|
||||
|
||||
return programa;
|
||||
return this.programaRepository.findOne({ where: { id_programa } });
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
return `This action updates a #${id} programa`;
|
||||
// CREAR
|
||||
async create(createProgramaDto: CreateProgramaDto) {
|
||||
const nuevo = this.programaRepository.create(createProgramaDto);
|
||||
return await this.programaRepository.save(nuevo);
|
||||
}
|
||||
|
||||
// ACTUALIZAR
|
||||
async update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
await this.programaRepository.update(id, updateProgramaDto);
|
||||
return await this.findOne(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user