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

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

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

  end

  def show
    @s_organisation = SOrganisation.find(params[:id])

  end

  def new
    @s_organisation = SOrganisation.new
  
  end

  def edit
    @s_organisation = SOrganisation.find(params[:id])
    
  end

  def create
    @s_organisation = SOrganisation.new(params.require(:s_organisation).permit!)

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

  end


  def update
    @s_organisation = SOrganisation.find(params[:id])


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


  def destroy
    @s_organisation = SOrganisation.find(params[:id])
    @s_organisation.destroy
    
  end
end
