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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @particular_hists = ParticularHist.all

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

  def show
    @particular_hist = ParticularHist.find(params[:id])

  end

  def new
    @particular_hist = ParticularHist.new
  
  end

  def edit
    @particular_hist = ParticularHist.find(params[:id])
    
  end

  def create
    @particular_hist = ParticularHist.new(params.require(:particular_hist).permit!)

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

  end


  def update
    @particular_hist = ParticularHist.find(params[:id])


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


  def destroy
    @particular_hist = ParticularHist.find(params[:id])
    @particular_hist.destroy
    
  end
end
