Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Danka Marcell committed Nov 27, 2024
1 parent db9369e commit 88736fb
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions apps/backend/src/band/band.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ export class BandService {
}

async addMember(bandId: number, userId: number): Promise<BandMembership> {
if (await this.prisma.bandMembership.findUnique({ where: { bandId: { bandId }, userId: { userId } } })) {
throw new NotFoundException('User is already a member of the band');
}
if (!(await this.prisma.user.findUnique({ where: { id: userId } }))) {
throw new NotFoundException('User does not exist');
}
try {
const res = await this.prisma.bandMembership.create({
BandMembership: { band: { connect: { id: bandId } }, user: { connect: { id: userId } } },
data: { band: { connect: { id: bandId } }, user: { connect: { id: userId } } },
});
if (!res) throw new Error();
return res;
Expand All @@ -87,9 +81,6 @@ export class BandService {
}

async removeMember(bandId: number, userId: number): Promise<BandMembership> {
if (!(await this.prisma.bandMembership.findUnique({ where: { bandId: { bandId }, userId: { userId } } }))) {
throw new NotFoundException('User is not a member of the band');
}
try {
const res = await this.prisma.bandMembership.delete({ where: { bandId, userId } });
if (!res) throw new Error();
Expand Down

0 comments on commit 88736fb

Please sign in to comment.