Class: Logistics::Core::BroadGaugeCntsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logistics/core/broad_gauge_cnts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /broad_gauge_cnts POST /broad_gauge_cnts.json



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/logistics/core/broad_gauge_cnts_controller.rb', line 19

def create
  broad_gauge_cnt = BroadGaugeCnt.new(broad_gauge_cnt_params)

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

#indexObject

GET /broad_gauge_cnts GET /broad_gauge_cnts.json



11
12
13
14
15
# File 'app/controllers/logistics/core/broad_gauge_cnts_controller.rb', line 11

def index
  broad_gauge_cnts = BroadGaugeCnt.fetch_all
  response = Mks::Common::MethodResponse.new(true, nil, broad_gauge_cnts, nil, nil)
  render json: response
end

#updateObject

PATCH/PUT /broad_gauge_cnts/1 PATCH/PUT /broad_gauge_cnts/1.json



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/logistics/core/broad_gauge_cnts_controller.rb', line 33

def update
  broad_gauge_cnt = BroadGaugeCnt.find(params[:id])

  if broad_gauge_cnt.update(broad_gauge_cnt_params)
    response = Mks::Common::MethodResponse.new(true, "Containerized Broad Gauge information updated successfully!", broad_gauge_cnt, nil)
  else
    errors = Mks::Common::Util.error_messages broad_gauge_cnt, "Containerzed Broad Gauge"
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
  end
  render json: response
end