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

class Admin::AdminPermissionsController < ApplicationController
  layout "admin"
  before_action :auth_admin
  
  before_action :is_super_admin
  
  before_action :admin_space
  
  def admin_space
    @admin_space = "preferences"
  end

  def index
    @admin_permissions = AdminPermission.order(:id).all

   
  end

  def show
    @admin_permission = AdminPermission.find(params[:id])

  end

  def new
    
    
		@admin_permission = AdminPermission.new
    

  end

 

  def edit
  
    
    @admin_permission = AdminPermission.find(params[:id])
  end

  def create
    @admin_permission = AdminPermission.new(params.require(:admin_permission).permit!)


    if @admin_permission.save
     @admin_permissions = AdminPermission.order(:id).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @admin_permission = AdminPermission.find(params[:id])


    if @admin_permission.update_attributes(params.require(:admin_permission).permit!)
      
       @admin_permissions = AdminPermission.order(:id).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @admin_permission = AdminPermission.find(params[:id])
    @admin_permission.destroy
    
    
  end
end
