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

class Admin::IHebergementsController < ApplicationController
  layout "admin"
  before_filter :auth_admin

  before_filter :admin_space
  
  def admin_space
    @admin_space = "sites"
  end
  

  
  
  def index
    @i_hebergements = IHebergement.order("p_customer_id ASC").all

   
  end

  def show
    @i_hebergement = IHebergement.find(params[:id])

  end

  def new
    
    
		@i_hebergement = IHebergement.new
    

  end

 

  def edit
  
    
    @i_hebergement = IHebergement.find(params[:id])
  end

  def create
    @i_hebergement = IHebergement.new(params.require(:i_hebergement).permit!)


    if @i_hebergement.save
     @i_hebergements = IHebergement.order("p_customer_id ASC").all
      
    else
      render action: "new"
 
    end

  end


  def update
    @i_hebergement = IHebergement.find(params[:id])


    if @i_hebergement.update_attributes(params.require(:i_hebergement).permit!)
      
       @i_hebergements = IHebergement.order("p_customer_id ASC").all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @i_hebergement = IHebergement.find(params[:id])
    @i_hebergement.destroy
    
    
  end
end
