Class: Mks::Rate::ServiceBundlesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mks/rate/service_bundles_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_servicesObject



47
48
49
50
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 47

def add_services
  result = @service.add_services(@service_bundle, add_services_params[:ids])
  render json: { success: result }
end

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 20

def create
  @service_bundle = ServiceBundle.new(service_bundle_params)
  if @service_bundle.save
    render json: @service_bundle, status: :created, location: @service_bundle
  else
    render json: @service_bundle.errors, status: :unprocessable_entity
  end
end

#filterObject



37
38
39
40
41
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 37

def filter
  search = "%#{params[:search].downcase}%"
  bundles = ServiceBundle.where('lower(mks_rate_service_bundles.name) LIKE ?', search)
  render json: bundles
end

#indexObject



6
7
8
9
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 6

def index
  @service_bundles = ServiceBundle.all
  render json: @service_bundles
end

#sdu_bundlesObject



11
12
13
14
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 11

def sdu_bundles
  result = ServiceBundle.where(service_delivery_unit_id: params[:id])
  render json: result
end

#servicesObject



43
44
45
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 43

def services
  render json: @service_bundle.chargeable_services
end

#showObject



16
17
18
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 16

def show
  render json: @service_bundle
end

#updateObject



29
30
31
32
33
34
35
# File 'app/controllers/mks/rate/service_bundles_controller.rb', line 29

def update
  if @service_bundle.update(service_bundle_params)
    render json: @service_bundle
  else
    render json: @service_bundle.errors, status: :unprocessable_entity
  end
end