class ExclusiveTraditionalRecordsController < ApplicationController
  before_action :set_exclusive_traditional_record, only: %i[ show edit update destroy ]

  # GET /exclusive_traditional_records or /exclusive_traditional_records.json
  def index
    @exclusive_traditional_records = ExclusiveTraditionalRecord.all
  end

  # GET /exclusive_traditional_records/1 or /exclusive_traditional_records/1.json
  def show
  end

  # GET /exclusive_traditional_records/new
  def new
    @exclusive_traditional_record = ExclusiveTraditionalRecord.new
  end

  # GET /exclusive_traditional_records/1/edit
  def edit
  end

  # POST /exclusive_traditional_records or /exclusive_traditional_records.json
  def create
    @exclusive_traditional_record = ExclusiveTraditionalRecord.new(exclusive_traditional_record_params)

    respond_to do |format|
      if @exclusive_traditional_record.save
        format.html { redirect_to @exclusive_traditional_record, notice: "Exclusive traditional record was successfully created." }
        format.json { render :show, status: :created, location: @exclusive_traditional_record }
      else
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @exclusive_traditional_record.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /exclusive_traditional_records/1 or /exclusive_traditional_records/1.json
  def update
    respond_to do |format|
      if @exclusive_traditional_record.update(exclusive_traditional_record_params)
        format.html { redirect_to @exclusive_traditional_record, notice: "Exclusive traditional record was successfully updated.", status: :see_other }
        format.json { render :show, status: :ok, location: @exclusive_traditional_record }
      else
        format.html { render :edit, status: :unprocessable_entity }
        format.json { render json: @exclusive_traditional_record.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /exclusive_traditional_records/1 or /exclusive_traditional_records/1.json
  def destroy
    @exclusive_traditional_record.destroy!

    respond_to do |format|
      format.html { redirect_to exclusive_traditional_records_path, notice: "Exclusive traditional record was successfully destroyed.", status: :see_other }
      format.json { head :no_content }
    end
  end

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

    # Only allow a list of trusted parameters through.
    def exclusive_traditional_record_params
      params.require(:exclusive_traditional_record).permit(:name, :author, :description, :pdf_file)
    end
end
