POSTprograms
This commit is contained in:
@@ -15,6 +15,10 @@ export class ProgramaController {
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.programaService.findOne(+id);
|
||||
}
|
||||
@Post()
|
||||
create(@Body() body) {
|
||||
return this.programaService.create(body);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaDto: UpdateProgramaDto) {
|
||||
|
||||
@@ -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