package za.co.rootbranch.coffeechat.services;

import java.util.List;

import org.springframework.stereotype.Service;

import za.co.rootbranch.coffeechat.models.Room;
import za.co.rootbranch.coffeechat.repositories.RoomRepository;

@Service
public class RoomService {

    private final RoomRepository roomRepository;

    public RoomService(RoomRepository repository) {
        this.roomRepository = repository;
    }

    public List<Room> findRooms() {
        return roomRepository.findAll();
    }

    public Room addRoom(Room room) {
        try {
            return roomRepository.save(room);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return null;
    }
}
