Tour package booking, app release, new endpoints, more updates and fixes

This commit is contained in:
Stephanos A
2026-07-05 00:28:06 +03:00
parent 868639084c
commit 595be6e123
68 changed files with 2773 additions and 787 deletions

View File

@@ -1,5 +1,6 @@
import { Injectable, NotFoundException, ConflictException } from '@nestjs/common';
import { PrismaService } from '../../common/prisma.service';
import { DeleteOperationException } from '../../common/exceptions/delete-operation.exception';
@Injectable()
export class SeatClassesService {
@@ -45,8 +46,24 @@ export class SeatClassesService {
}
async deleteSeatClass(id: string) {
const sc = await this.prisma.seatClass.findUnique({ where: { id } });
const sc = await this.prisma.seatClass.findUnique({
where: { id },
include: {
_count: { select: { fareRules: true, routeFareRules: true, segmentFares: true } },
},
});
if (!sc) throw new NotFoundException('SeatClass not found');
const totalFareRules =
(sc as any)._count.fareRules +
(sc as any)._count.routeFareRules +
(sc as any)._count.segmentFares;
if (totalFareRules > 0)
throw new DeleteOperationException('Seat Class', sc.name, [
{ entityName: 'fare rule', count: totalFareRules, action: 'delete' },
]);
return this.prisma.seatClass.delete({ where: { id } });
}
}