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

class Public::MOdrRepsController < ApplicationController
  layout "public"
 
  
  def new
    @m_odr_rep = MOdrRep.new
  
  end

  def edit
    @m_odr_rep = MOdrRep.find(params[:id])
    
  end

  def create
    @m_odr_rep = MOdrRep.new(params.require(:m_odr_rep).permit!)
    @m_odr = @m_odr_rep.m_odr
    
    if @m_odr_rep.save
      @m_odr_rep.send_mail_type("confirmation-inscription")
    
      
      redirect_to thank_public_m_odr_rep_path(@m_odr_rep)
      
      
      
    else
      render :template => "public/m_odrs/show"
 
    end

  end


  def thank
    @m_odr_rep = MOdrRep.find(params[:id])
    @m_odr = @m_odr_rep.m_odr
    
    
    
  end

  def update
    @m_odr_rep = MOdrRep.find(params[:id])


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


end
