Sha256: c234ace8e556016b9451b479e855f19d9e6b059507c3225af4381fee566cd2ce

Contents?: true

Size: 1.88 KB

Versions: 9

Compression:

Stored size: 1.88 KB

Contents

module Logistics
  module Core
    class ServiceDeliveryUnitServicesController < ApplicationController

      # POST /service_delivery_unit_services
      # POST /service_delivery_unit_services.json
      def create
        sdu_services = params[:service_delivery_unit_services]
        if sdu_services.count > 0
          sdu = Logistics::Core::ServiceDeliveryUnit.find sdu_services[0][:service_delivery_unit_id]
        end
        sdu_services.each do |sdu_service|
          Logistics::Core::ServiceDeliveryUnitChargeableService.create('service_delivery_unit_id' => sdu_service[:service_delivery_unit_id],
                                                 'chargeable_service_id' => sdu_service[:chargeable_service_id],
                                                 'is_mandatory' => sdu_service[:is_mandatory] )
        end
        response = {:success => true, :message => 'Service delivery unit service(s) recorded successfully'}
        render json: response
      end

      def update
        sdu_service = Logistics::Core::ServiceDeliveryUnitChargeableService.find(params[:id])
        sdu_service.is_mandatory = params[:edited_row][:is_mandatory]
        sdu_service.save
        response = Mks::Common::MethodResponse.new(true, 'Service updated successfully !', nil, nil, nil)
        render json: response
      end

      def delete
        sdu_service = ServiceDeliveryUnitServiceService.new
        sdu_service.delete_services(params[:id])
        response = Mks::Common::MethodResponse.new(true, 'Service deleted successfully !', nil, nil, nil)
        render json: response
      end

      private

        # Never trust parameters from the scary internet, only allow the white list through.
        def service_delivery_unit_service_params
          params.permit(:service_delivery_unit_services => [:service_delivery_unit_id, :chargeable_service_id, :is_mandatory])
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/service_delivery_unit_services_controller.rb