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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @price_lines = PriceLine.order(:name).all

  end

  def show
    @price_line = PriceLine.find(params[:id])

  end

  def new
    @price_line = PriceLine.new
  
  end

  def edit
    @price_line = PriceLine.find(params[:id])
    
  end

  def create
    @price_line = PriceLine.new(params.require(:price_line).permit!)

    if @price_line.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @price_line = PriceLine.find(params[:id])


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


  def destroy
    @price_line = PriceLine.find(params[:id])
    @price_line.destroy
    
  end
end
