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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "tournees"
  end
  
  def index
    @file_tunel_files = FileTunelFile.all
    
    @file_tunel_files = sort_by_sorting(@file_tunel_files, "created_at DESC")
    
    
    params[:search][:per_page] = params[:search][:per_page] || 50
		per_page = params[:search][:per_page]
		page = (params[:page] and params[:page] != "") ? params[:page] : 1 
		@file_tunel_files = @file_tunel_files.page(page).per(per_page)
    

  end

  def show
    @file_tunel_file = FileTunelFile.find(params[:id])

  end

  def new
    @file_tunel_file = FileTunelFile.new
  
  end

  def edit
    @file_tunel_file = FileTunelFile.find(params[:id])
    
  end

  def create
    @file_tunel_file = FileTunelFile.new(params.require(:file_tunel_file).permit!)

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

  end


  def update
    @file_tunel_file = FileTunelFile.find(params[:id])


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


  def destroy
    @file_tunel_file = FileTunelFile.find(params[:id])
    @file_tunel_file.destroy
    
  end
end
