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

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

  before_action :admin_space
  
  def admin_space
    @admin_space = "todos"
  end
  
  def index
    @i_task_projects = ITaskProject.order(:name).all

  end

  def show
    @i_task_project = ITaskProject.find(params[:id])

  end

  def new
    @i_task_project = ITaskProject.new
  
  end

  def edit
    @i_task_project = ITaskProject.find(params[:id])
    
  end

  def create
    @i_task_project = ITaskProject.new(params.require(:i_task_project).permit!)

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

  end


  def update
    @i_task_project = ITaskProject.find(params[:id])


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


  def destroy
    @i_task_project = ITaskProject.find(params[:id])
    @i_task_project.destroy
    
  end
end
