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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "tournees"
  end
  
  def index
    @file_tunel_downloads = FileTunelDownload.all
    
    @file_tunel_downloads = sort_by_sorting(@file_tunel_downloads, "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_downloads = @file_tunel_downloads.page(page).per(per_page)
    

  end

  def show
    @file_tunel_download = FileTunelDownload.find(params[:id])

  end

  def new
    @file_tunel_download = FileTunelDownload.new
  
  end

  def edit
    @file_tunel_download = FileTunelDownload.find(params[:id])
    
  end

  def create
    @file_tunel_download = FileTunelDownload.new(params.require(:file_tunel_download).permit!)

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

  end


  def update
    @file_tunel_download = FileTunelDownload.find(params[:id])


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


  def destroy
    @file_tunel_download = FileTunelDownload.find(params[:id])
    @file_tunel_download.destroy
    
  end
end
