import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class BedRoomsService {
  constructor(private prisma: PrismaService) {}

  async findAll() {
    return this.prisma.bedRoom.findMany({
      where: { status: true },
      orderBy: { orderNo: 'asc' },
    });
  }

  async adminFindAll() {
    return this.prisma.bedRoom.findMany({ orderBy: { orderNo: 'asc' } });
  }

  async create(data: { name: string; kelas: string; capacity: number; orderNo?: number; status?: boolean }) {
    return this.prisma.bedRoom.create({ data });
  }

  async update(id: number, data: { name?: string; kelas?: string; capacity?: number; orderNo?: number; status?: boolean }) {
    return this.prisma.bedRoom.update({ where: { id }, data });
  }

  async remove(id: number) {
    return this.prisma.bedRoom.delete({ where: { id } });
  }
}
