@RequestMapping(value = "/rooms", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Room createRoom(@Valid @RequestBody Room room) { Room newRoom = new Room(room.getName(), room.getCampusName(), room.getCapacity(), room.isVc()); roomsRepository.save(newRoom); return newRoom; }
@RequestMapping(value = "/rooms", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public List getAllRooms() { List roomList = new ArrayList<Room>(); roomList = roomsRepository.findAll(); return roomList; }
@RequestMapping(value = "/rooms/{id}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Room getRoomById(@PathVariable String id) throws RoomNotFoundException { Room room = new Room(); room = roomsRepository.findOne(id); if (room == null) { // return new ResponseEntity<Room>(HttpStatus.NOT_FOUND); // throw new RoomNotFoundException("Room is not found in the database1"); throw new RoomNotFoundException(); } return room; }