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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @a_sites = ASite.order(:name).all

  end

  def show
    @a_site = ASite.find(params[:id])

  end

  def new
    @a_site = ASite.new
  
  end

  def edit
    @a_site = ASite.find(params[:id])
    
  end

  def create
    @a_site = ASite.new(params.require(:a_site).permit!)

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

  end


  def update
    @a_site = ASite.find(params[:id])


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


  def destroy
    @a_site = ASite.find(params[:id])
    @a_site.destroy
    
  end
end
