class TodoNotesController < ApplicationController
  before_action :set_todo_note, only: [:show, :edit, :update, :destroy]

  # GET /todo_notes
  # GET /todo_notes.json
  def index
    @todo_notes = TodoNote.all
  end

  # GET /todo_notes/1
  # GET /todo_notes/1.json
  def show
  end

  # GET /todo_notes/new
  def new
    @todo_note = TodoNote.new
  end

  # GET /todo_notes/1/edit
  def edit
  end

  # POST /todo_notes
  # POST /todo_notes.json
  def create
    @todo_note = TodoNote.new(todo_note_params)

    respond_to do |format|
      if @todo_note.save
        format.html { redirect_to @todo_note, notice: 'Todo note was successfully created.' }
        format.json { render :show, status: :created, location: @todo_note }
      else
        format.html { render :new }
        format.json { render json: @todo_note.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /todo_notes/1
  # PATCH/PUT /todo_notes/1.json
  def update
    respond_to do |format|
      if @todo_note.update(todo_note_params)
        format.html { redirect_to @todo_note, notice: 'Todo note was successfully updated.' }
        format.json { render :show, status: :ok, location: @todo_note }
      else
        format.html { render :edit }
        format.json { render json: @todo_note.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /todo_notes/1
  # DELETE /todo_notes/1.json
  def destroy
    @todo_note.destroy
    respond_to do |format|
      format.html { redirect_to todo_notes_url, notice: 'Todo note was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_todo_note
      @todo_note = TodoNote.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def todo_note_params
      params.require(:todo_note).permit(:description, :deadLine)
    end
end
