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

class Admin::AdminRolesController < 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_roles = AdminRole.order(:name).all

   
  end

  def show
    @admin_role = AdminRole.find(params[:id])

  end

  def new
    
    
		@admin_role = AdminRole.new
    

  end

 

  def edit
  
    
    @admin_role = AdminRole.find(params[:id])
  end

  def create
    @admin_role = AdminRole.new(params.require(:admin_role).permit!)


    if @admin_role.save
     @admin_roles = AdminRole.order(:name).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @admin_role = AdminRole.find(params[:id])


    if @admin_role.update_attributes(params.require(:admin_role).permit!)
      
       @admin_roles = AdminRole.order(:name).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @admin_role = AdminRole.find(params[:id])
    @admin_role.destroy
    
    
  end
end
