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

class Public::KapsController < ApplicationController
  layout "public"
  before_filter :auth_p_customer


  def index
    @kaps = current_p_customer.kaps.order(:name).all

   
  end

  def show
    @kap = current_p_customer.kaps.find(params[:id])

  end

  def new
    
    
		@kap = current_p_customer.kaps.new
    

  end

 

  def edit
  
    
    @kap = current_p_customer.kaps.find(params[:id])
  end

  def create
    @kap = current_p_customer.kaps.new(params.require(:kap).permit!)


    if @kap.save
     @kaps = current_p_customer.kaps.order(:name).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @kap = current_p_customer.kaps.find(params[:id])


    if @kap.update_attributes(params.require(:kap).permit!)
      
       @kaps = current_p_customer.kaps.order(:name).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @kap = current_p_customer.kaps.find(params[:id])
    @kap.destroy
    
    
  end
end
