module Logistics module Core class TruckTypeBbWeightRangesController < ApplicationController protect_from_forgery with: :null_session before_action :set_truck_type_bb_weight_range, only: [:update] # GET /truck_type_bb_weight_ranges # GET /truck_type_bb_weight_ranges.json def index break_bulk_truck_assignment_id = params[:id] truck_type_bb_weight_ranges = TruckTypeBbWeightRange.fetch_all break_bulk_truck_assignment_id response = Mks::Common::MethodResponse.new(true, nil, truck_type_bb_weight_ranges, nil, nil) render json: response end # POST /truck_type_bb_weight_ranges # POST /truck_type_bb_weight_ranges.json def create truck_type_bb_weight_range = TruckTypeBbWeightRange.new(truck_type_bb_weight_range_params) if truck_type_bb_weight_range.save response = Mks::Common::MethodResponse.new(true, "Break Bulk Truck Type assignment information saved successfully!", truck_type_bb_weight_range, nil, nil) else errors = Mks::Common::Util.error_messages truck_type_bb_weight_range, "Break Bulk Truck Assignment" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end # PATCH/PUT /truck_type_bb_weight_ranges/1 # PATCH/PUT /truck_type_bb_weight_ranges/1.json def update truck_type_bb_weight_range = TruckTypeBbWeightRange.find(params[:id]) if truck_type_bb_weight_range.update(truck_type_bb_weight_range_params) response = Mks::Common::MethodResponse.new(true, "Break Bulk Truck Type assignment information updated successfully!", truck_type_bb_weight_range, nil, nil) else errors = Mks::Common::Util.error_messages truck_type_bb_weight_range, "Break Bulk Truck Assignment" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end private def set_truck_type_bb_weight_range @truck_type_bb_weight_range = TruckTypeBbWeightRange.find(params[:id]) end def truck_type_bb_weight_range_params params.require(:truck_type_bb_weight_range).permit(:break_bulk_truck_assignment_id, :weight_range_id) end end end end