Sha256: 9d411c6391eb54ae0622c8f77bfe8b9d4672dcd60e36dbcc181c9d0a0544bbd4

Contents?: true

Size: 1.88 KB

Versions: 9

Compression:

Stored size: 1.88 KB

Contents

require_dependency 'application_controller'

module Logistics
  module Core
    class BroadGaugeBbsController < ApplicationController
      protect_from_forgery with: :null_session
      before_action :set_broad_gauge_bb, only: [:update]

      # GET /broad_gauge_bbs
      # GET /broad_gauge_bbs.json
      def index
        broad_gauge_bbs = BroadGaugeBb.fetch_all
        response = Mks::Common::MethodResponse.new(true, nil, broad_gauge_bbs, nil, nil)
        render json: response
      end

      # POST /broad_gauge_bbs
      # POST /broad_gauge_bbs.json
      def create
        broad_gauge_bb = BroadGaugeBb.new(broad_gauge_bb_params)

        if broad_gauge_bb.save
          response = Mks::Common::MethodResponse.new(true, "Break Bulk Broad Gauge information saved successfully!", broad_gauge_bb, nil)
        else
          errors = Mks::Common::Util.error_messages broad_gauge_bb, "Break Bulk Broad Gauge"
          response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: response
      end

      # PATCH/PUT /broad_gauge_bbs/1
      # PATCH/PUT /broad_gauge_bbs/1.json
      def update
        broad_gauge_bb = BroadGaugeBb.find(params[:id])

        if broad_gauge_bb.update(broad_gauge_bb_params)
          response = Mks::Common::MethodResponse.new(true, "Break Bulk Broad Gauge information updated successfully!", broad_gauge_bb, nil)
        else
          errors = Mks::Common::Util.error_messages broad_gauge_bb, "Break Bulk Broad Gauge"
          response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: response
      end

      private

      def set_broad_gauge_bb
        @broad_gauge_bb = BroadGaugeBb.find(params[:id])
      end

      def broad_gauge_bb_params
        params.require(:broad_gauge_bb).permit(:break_bulk_unit_id, :length, :width, :height, :actual_weight)
      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/broad_gauge_bbs_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/broad_gauge_bbs_controller.rb