# -*- encoding : utf-8 -*-

class Admin::PriceLineRespSelectsController < ApplicationController
  layout "admin"
  before_action :auth_admin

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @price_line_resp_selects = PriceLineRespSelect.all

    @price_line_resp_selects = sort_by_sorting(@price_line_resp_selects, "id DESC")
    respond_to do |format|
      format.html{
      
        params[:search][:per_page] = params[:search][:per_page] || 100
        per_page = params[:search][:per_page]
        page = (params[:page] and params[:page] != "") ? params[:page] : 1 
        @price_line_resp_selects = @price_line_resp_selects.page(page).per(per_page)
      
      }
    end
  end

  def show
    @price_line_resp_select = PriceLineRespSelect.find(params[:id])

  end

  def new
    @price_line_resp_select = PriceLineRespSelect.new
  
  end

  def edit
    @price_line_resp_select = PriceLineRespSelect.find(params[:id])
    
  end

  def create
    @price_line_resp_select = PriceLineRespSelect.new(params.require(:price_line_resp_select).permit!)

    if @price_line_resp_select.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @price_line_resp_select = PriceLineRespSelect.find(params[:id])


    if @price_line_resp_select.update_attributes(params.require(:price_line_resp_select).permit!)
      
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @price_line_resp_select = PriceLineRespSelect.find(params[:id])
    @price_line_resp_select.destroy
    
  end
end
