Class: Logistics::Core::ChargeableServiceIncrementsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /chargeable_service_increments POST /chargeable_service_increments.json



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/logistics/core/chargeable_service_increments_controller.rb', line 16

def create
  uoc_list = params[:increments]
  cs_uoc = nil
  if uoc_list.count > 0
    cs_uoc = ChargeableServiceUnitOfCharge.find(uoc_list[0][:chargeable_service_unit_of_charge_id])
  end

  uoc_list.each do |uoc|
    increment = ServiceIncrement.find(uoc[:service_increment_id])
    cs_uoc.service_increments << increment
  end
  begin
    cs_uoc.save
    response = {:success => true, :message => 'Service Increment successfully'}
  rescue => e
    response = {:success => false, :message => e.message}
  end
  render json: response
end

#indexObject

GET /chargeable_service_increments GET /chargeable_service_increments.json



7
8
9
10
11
# File 'app/controllers/logistics/core/chargeable_service_increments_controller.rb', line 7

def index
  @chargeable_service_increments = ChargeableServiceIncrement.all
  @response = {:success => true, :message => '', :data => @chargeable_service_increments}
  render json: @response
end