Class: Logistics::Core::CustomsTransportTariffsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/logistics/core/customs_transport_tariffs_controller.rb', line 13

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

#indexObject



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

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

#updateObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/logistics/core/customs_transport_tariffs_controller.rb', line 24

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