require_dependency 'application_controller' module Logistics module Core class BreakBulkTruckAssignmentsController < ApplicationController protect_from_forgery with: :null_session before_action :set_break_bulk_truck_assignment, only: [:update] # GET /break_bulk_truck_assignments # GET /break_bulk_truck_assignments.json def index @break_bulk_truck_assignments = BreakBulkTruckAssignment.fetch_all response = Mks::Common::MethodResponse.new(true, nil, @break_bulk_truck_assignments, nil, nil) render json: response end # POST /break_bulk_truck_assignments # POST /break_bulk_truck_assignments.json def create break_bulk_truck_assignment = BreakBulkTruckAssignment.new(break_bulk_truck_assignment_params) if break_bulk_truck_assignment.save response = Mks::Common::MethodResponse.new(true, "Break Bulk Truck Type Assignment record saved successfully!",break_bulk_truck_assignment, nil, nil) else errors = Mks::Common::Util.error_messages break_bulk_truck_assignment, "Break Bulk Truck Assignment" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end # PATCH/PUT /break_bulk_truck_assignments/1 # PATCH/PUT /break_bulk_truck_assignments/1.json def update break_bulk_truck_assignment = set_break_bulk_truck_assignment if break_bulk_truck_assignment.update(break_bulk_truck_assignment_params) response = Mks::Common::MethodResponse.new(true, "Break Bulk Truck Type Assignment record updated successfully!", break_bulk_truck_assignment, nil, nil) else errors = Mks::Common::Util.error_messages break_bulk_truck_assignment, "Break Bulk Truck Assignment" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end private def set_break_bulk_truck_assignment @break_bulk_truck_assignment = BreakBulkTruckAssignment.find(params[:id]) end def break_bulk_truck_assignment_params params.require(:break_bulk_truck_assignment).permit(:truck_type) end end end end