Class: Logistics::Core::TwentyFeetEquivalenceRatiosController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/logistics/core/twenty_feet_equivalence_ratios_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /chargeable_services POST /chargeable_services.json



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/logistics/core/twenty_feet_equivalence_ratios_controller.rb', line 22

def create
  twenty_feet_equivalence_ratio = TwentyFeetEquivalenceRatio.new(twenty_feet_equivalence_ratio_parms)
  if twenty_feet_equivalence_ratio.valid?
    twenty_feet_equivalence_ratio.save
    @response = Mks::Common::MethodResponse.new(true, 'Equivalence ratio saved successfully !', nil, nil)
    render json: @response
  else
    errors = Mks::Common::Util.error_messages(twenty_feet_equivalence_ratio, 'TEU')
    response = Mks::Common::MethodResponse.new(false,nil,nil,errors,nil)
    render json: response
  end
  #end
  #end
end

#indexObject

GET /chargeable_services GET /chargeable_services.json



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/logistics/core/twenty_feet_equivalence_ratios_controller.rb', line 8

def index
  twenty_feet_equivalence_ratio = []
  twenty_feet_equivalences = TwentyFeetEquivalenceRatio.all
  twenty_feet_equivalences.each{ |tfe|
    twenty_feet_equivalence_ratio.push({:id => tfe.id, :container_size_name => tfe.container_size.name,
                                        :container_size_id => tfe.container_size_id,
                                        :ratio => tfe.ratio})
  }
  @response = Mks::Common::MethodResponse.new(true, nil, twenty_feet_equivalence_ratio, nil, nil)
  render json: @response
end

#updateObject

PATCH/PUT /chargeable_services/1 PATCH/PUT /chargeable_services/1.json



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/logistics/core/twenty_feet_equivalence_ratios_controller.rb', line 39

def update
  @twenty_feet_equivalence_ratio.update_attributes(twenty_feet_equivalence_ratio_parms)
  if @twenty_feet_equivalence_ratio.save
    @response = Mks::Common::MethodResponse.new(true, 'Equivalence ratio update successfully !', nil, nil, nil)
    render json: @response
  else
    errors = Mks::Common::Util.error_messages(@twenty_feet_equivalence_ratio, 'TEU')
    response = Mks::Common::MethodResponse.new(false,nil,nil,errors,nil)
    render json: response
  end
end