module Logistics module Core class TruckTypeCntWeightRangesController < ApplicationController protect_from_forgery with: :null_session before_action :set_truck_type_cnt_weight_range, only: [:update] # GET /truck_type_cnt_weight_ranges # GET /truck_type_cnt_weight_ranges.json def index truck_type_assignment_id = params[:id] truck_type_cnt_weight_ranges = TruckTypeCntWeightRange.fetch_all truck_type_assignment_id response = Mks::Common::MethodResponse.new(true, nil, truck_type_cnt_weight_ranges, nil, nil) render json: response end # POST /truck_type_cnt_weight_ranges # POST /truck_type_cnt_weight_ranges.json def create truck_type_cnt_weight_range = TruckTypeCntWeightRange.new(truck_type_cnt_weight_range_params) if truck_type_cnt_weight_range.save response = Mks::Common::MethodResponse.new(true, "Container Truck type assignment information saved successfully!", truck_type_cnt_weight_range, nil, nil) else errors = Mks::Common::Util.error_messages truck_type_cnt_weight_range, "Containerized Truck Type Assignment:" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end # PATCH/PUT /truck_type_cnt_weight_ranges/1 # PATCH/PUT /truck_type_cnt_weight_ranges/1.json def update truck_type_cnt_weight_range = TruckTypeCntWeightRange.find(params[:id]) if truck_type_cnt_weight_range.update(truck_type_cnt_weight_range_params) response = Mks::Common::MethodResponse.new(true, "Container Truck type assignment information updated successfully!", truck_type_cnt_weight_range, nil, nil) else errors = Mks::Common::Util.error_messages truck_type_cnt_weight_range, "Containerized Truck Type Assignment:" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end # DELETE /truck_type_cnt_weight_ranges/1 # DELETE /truck_type_cnt_weight_ranges/1.json def destroy @truck_type_cnt_weight_range.destroy head :no_content end private def set_truck_type_cnt_weight_range @truck_type_cnt_weight_range = TruckTypeCntWeightRange.find(params[:id]) end def truck_type_cnt_weight_range_params params.require(:truck_type_cnt_weight_range).permit(:truck_type_assignment_id, :weight_range_id) end end end end