Sha256: 199f5960c6b8e16d029fcb56dda64131b4fe6d2ef4c2fb3081b7ac10fb574396

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

module Mks
  module Rate
    class ServiceDeliveryUnitsController < ApplicationController
      before_action :set_service_delivery_unit, only: [:update]

      def index
        result = ServiceDeliveryUnit.all
        render json: result
      end

      def create
        sdu = ServiceDeliveryUnit.new(service_delivery_unit_params)
        if sdu.save
          render json: Mks::Common::MethodResponse.success_response(sdu, 'Service delivery unit saved successfully !')
        else
          render json: Mks::Common::MethodResponse.failure_response(sdu), status: :unprocessable_entity
        end
      end

      def update
        if @sdu.update(service_delivery_unit_params)
          render json: Mks::Common::MethodResponse.success_response(@sdu, 'Service delivery unit updated successfully !')
        else
          render json: Mks::Common::MethodResponse.failure_response(@sdu), status: :unprocessable_entity
        end
      end

      private

      def service_delivery_unit_params
        params.require(:service_delivery_unit).permit(:id, :code, :name, :address)
      end

      def set_service_delivery_unit
        @sdu = ServiceDeliveryUnit.find(params[:id])
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mks_rate-1.0.5 app/controllers/mks/rate/service_delivery_units_controller.rb
mks_rate-1.0.4 app/controllers/mks/rate/service_delivery_units_controller.rb
mks_rate-1.0.3 app/controllers/mks/rate/service_delivery_units_controller.rb
mks_rate-1.0.2 app/controllers/mks/rate/service_delivery_units_controller.rb
mks_rate-1.0.1 app/controllers/mks/rate/service_delivery_units_controller.rb