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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "stocks"
  end
  
  def index
    @m_odrs = MOdr.order(:name).all

  end

  def show
    @m_odr = MOdr.find(params[:id])

  end

  def new
    @m_odr = MOdr.new
  
  end

  def edit
    @m_odr = MOdr.find(params[:id])
    
  end

  def create
    @m_odr = MOdr.new(params.require(:m_odr).permit!)

    if @m_odr.save
      redirect_to admin_m_odrs_path
    else
      render action: "new"
 
    end

  end


  def update
    @m_odr = MOdr.find(params[:id])


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


  def destroy
    @m_odr = MOdr.find(params[:id])
    @m_odr.destroy
    
  end
end
