merge Carlos
This commit is contained in:
@@ -9,7 +9,7 @@ export class MesaService {
|
||||
constructor(
|
||||
@InjectRepository(Mesa)
|
||||
private readonly mesaRepository: Repository<Mesa>,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
async findAll(): Promise<Mesa[]> {
|
||||
return await this.mesaRepository.find();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -9,25 +9,33 @@ import { Repository } from 'typeorm';
|
||||
export class ProgramaService {
|
||||
constructor(
|
||||
@InjectRepository(Programa)
|
||||
private readonly programaRepository:Repository<Programa>
|
||||
){}
|
||||
private readonly programaRepository: Repository<Programa>
|
||||
) { }
|
||||
|
||||
findAll() {
|
||||
return this.programaRepository.find({order:{programa:'ASC'}});
|
||||
return this.programaRepository.find({ order: { programa: 'ASC' } });
|
||||
}
|
||||
|
||||
|
||||
findOne(id_programa: number) {
|
||||
const programa = this.programaRepository.findOne({where:{id_programa}})
|
||||
const programa = this.programaRepository.findOne({ where: { id_programa } })
|
||||
|
||||
if(!programa){
|
||||
if (!programa) {
|
||||
return "this program dosnt exist"
|
||||
}
|
||||
|
||||
return programa;
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
return `This action updates a #${id} programa`;
|
||||
async create(createProgramaDto: CreateProgramaDto) {
|
||||
const nuevo = this.programaRepository.create(createProgramaDto);
|
||||
return await this.programaRepository.save(nuevo);
|
||||
}
|
||||
|
||||
async update(id: number, updateProgramaDto: UpdateProgramaDto) {
|
||||
await this.programaRepository.update(id, updateProgramaDto);
|
||||
return await this.findOne(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user