Class: Logistics::Core::EslTransportTariffRatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logistics/core/esl_transport_tariff_rates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/logistics/core/esl_transport_tariff_rates_controller.rb', line 20

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

#filter_by_tariffObject



13
14
15
16
17
18
# File 'app/controllers/logistics/core/esl_transport_tariff_rates_controller.rb', line 13

def filter_by_tariff
  esl_transport_tariff_rates = EslTransportTariffRate.where(:esl_transport_tariff_id => params[:id])
  data = ActiveModelSerializers::SerializableResource.new(esl_transport_tariff_rates).as_json
  response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil)
  render json: response
end

#indexObject



6
7
8
9
10
11
# File 'app/controllers/logistics/core/esl_transport_tariff_rates_controller.rb', line 6

def index
  esl_transport_tariff_rates = EslTransportTariffRate.all
  data = ActiveModelSerializers::SerializableResource.new(esl_transport_tariff_rates).as_json
  response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil)
  render json: response
end

#updateObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/logistics/core/esl_transport_tariff_rates_controller.rb', line 31

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