Sha256: 86a51acc49e402daf3bfb50b243f137cd825f4a2471390854651b907ee76c505
Contents?: true
Size: 1.88 KB
Versions: 9
Compression:
Stored size: 1.88 KB
Contents
module Logistics module Core class CustomsTransportTariffsController < ApplicationController before_action :set_customs_transport_tariff, only: [:update] 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 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 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 private def set_customs_transport_tariff @customs_transport_tariff = CustomsTransportTariff.find(params[:id]) end def customs_transport_tariff_params params.require(:customs_transport_tariff).permit(:route_id, :entry_point_id, :total_distance, :distance_to_entry_point, :proportion) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems