# -*- encoding : utf-8 -*-
class Admin::FileFoldersController < ApplicationController
  before_action :auth_admin


  def index
    @file_folders = FileFolder.all(:order => :name)
  end

  def new
    @file_folder = FileFolder.new()
  end

  def create
    @file_folder = FileFolder.new(params.require(:file_folder).permit!)
    @file_folder_create = true
    
    if @file_folder.save
      @file_folders = FileFolder.order(:name).all
    else
      render :action => :new
    
    end
  end

  def edit
    @file_folder = FileFolder.find(params[:id])  
  end

  def update
    @file_folder = FileFolder.find(params[:id])
    @file_folder_update = true
    
    if @file_folder.update_attributes(params.require(:file_folder).permit!)
      @file_folders = FileFolder.order(:name).all
    else
      render :action => :edit
    
    end
  end

  def destroy
    @file_folder = FileFolder.find(params[:id])
    if @file_folder.id != 1
      @file_folder.delete
      @file_folders = FileFolder.order(:name).all
    end
  end

end
