Sha256: 1c5c242e43488a7e1290cc013ac659d56786bd1b613685756ec0f65a07bf613f

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

module Logistics
  module Core
    class EslTransportTariffsController < ApplicationController
      before_action :set_esl_transport_tariff, only: [:update]

      def index
        esl_transport_tariffs = EslTransportTariff.includes(:route)
        data = ApplicationRecord.as_json(esl_transport_tariffs)
        response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil)
        render json: response
      end

      def create
        @esl_transport_tariff = EslTransportTariff.new(esl_transport_tariff_params)
        if @esl_transport_tariff.save
          response = Mks::Common::MethodResponse.new(true, 'ESL transport tariff saved successfully!', @esl_transport_tariff, nil, nil)
        else
          errors = Mks::Common::Util.error_messages @esl_transport_tariff, 'ESL transport tariff'
          response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: response
      end

      def update
        if @esl_transport_tariff.update(esl_transport_tariff_params)
          response = Mks::Common::MethodResponse.new(true, "ESL transport tariff updated successfully!", @esl_transport_tariff, nil, nil)
        else
          errors = Mks::Common::Util.error_messages @esl_transport_tariff, "ESL transport tariff"
          response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: response
      end

      private

      def set_esl_transport_tariff
        @esl_transport_tariff = EslTransportTariff.find(params[:id])
      end

      def esl_transport_tariff_params
        params.require(:esl_transport_tariff).permit(:route_id, :storage_point)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/esl_transport_tariffs_controller.rb