class PodujatieKlientisController < ApplicationController
  # GET /podujatie_klientis
  # GET /podujatie_klientis.json
  def index
    @podujatie = Podujatium.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @podujatie_klienti}
    end
  end

  # GET /podujatie_klientis/1
  # GET /podujatie_klientis/1.json
  def show
    @podujatie_klienti = PodujatieKlienti.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @podujatie_klienti }
    end
  end

  # GET /podujatie_klientis/new
  # GET /podujatie_klientis/new.json
  def new
    @podujatie = Podujatium.find(params[:id])

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @podujatie_klienti }
    end
  end

  # GET /podujatie_klientis/1/edit
  def edit
    @podujatie_klienti = PodujatieKlienti.find(params[:id])
  end

  # POST /podujatie_klientis
  # POST /podujatie_klientis.json
  def create
    @podujatie = Podujatium.find(params[:id])
    @klienti = Klienti.find(params[:podujatie][:klienti])
    
    @podujatie.klienti << @klienti
    
    redirect_to  podujatie_klientis_path
  end

  # PUT /podujatie_klientis/1
  # PUT /podujatie_klientis/1.json
  def update
    @podujatie_klienti = PodujatieKlienti.find(params[:id])

    respond_to do |format|
      if @podujatie_klienti.update_attributes(params[:podujatie_klienti])
        format.html { redirect_to @podujatie_klienti, notice: 'Podujatie klienti was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @podujatie_klienti.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /podujatie_klientis/1
  # DELETE /podujatie_klientis/1.json
  def destroy
    @podujatie_klienti = PodujatieKlienti.find(params[:id])
    @podujatie_klienti.destroy

    respond_to do |format|
      format.html { redirect_to podujatie_klientis_url }
      format.json { head :no_content }
    end
  end
end
