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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @partition_lines = PartitionLine.all

    @partition_lines = sort_by_sorting(@partition_lines, "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 
        @partition_lines = @partition_lines.page(page).per(per_page)
      
      }
    end
  end

  def show
    @partition_line = PartitionLine.find(params[:id])

  end

  def new
    @partition_line = PartitionLine.new
  
  end

  def edit
    @partition_line = PartitionLine.find(params[:id])
    
  end

  def create
    @partition_line = PartitionLine.new(params.require(:partition_line).permit!)

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

  end


  def update
    @partition_line = PartitionLine.find(params[:id])


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


  def destroy
    @partition_line = PartitionLine.find(params[:id])
    @partition_line.destroy
    
  end
end
