Zone and OQS
This commit is contained in:
81
app/controllers/settings/rooms_controller.rb
Normal file
81
app/controllers/settings/rooms_controller.rb
Normal file
@@ -0,0 +1,81 @@
|
||||
class Settings::RoomsController < ApplicationController
|
||||
before_action :set_settings_room, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
|
||||
# GET /settings/rooms
|
||||
# GET /settings/rooms.json
|
||||
def index
|
||||
@settings_rooms = @zone.rooms
|
||||
end
|
||||
|
||||
# GET /settings/rooms/1
|
||||
# GET /settings/rooms/1.json
|
||||
def show
|
||||
@room = Room.find(params[:id])
|
||||
end
|
||||
|
||||
# GET /settings/rooms/new
|
||||
def new
|
||||
@settings_room = Room.new
|
||||
end
|
||||
|
||||
# GET /settings/rooms/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/rooms
|
||||
# POST /settings/rooms.json
|
||||
def create
|
||||
@settings_room = Room.new(settings_room_params)
|
||||
@settings_room.type = DiningFacility::ROOM_TYPE
|
||||
@settings_room.zone_id = params[:zone_id]
|
||||
respond_to do |format|
|
||||
if @settings_room.save
|
||||
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_room }
|
||||
else
|
||||
puts "abc"
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/rooms/1
|
||||
# PATCH/PUT /settings/rooms/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_room.update(settings_room_params)
|
||||
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_room }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/rooms/1
|
||||
# DELETE /settings/rooms/1.json
|
||||
def destroy
|
||||
@settings_room.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_zones_path, notice: 'Room was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_room
|
||||
@settings_room = Room.find(params[:id])
|
||||
end
|
||||
|
||||
def set_settings_zone
|
||||
@zone = Zone.find(params[:zone_id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_room_params
|
||||
params.require(:room).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user