Sha256: a6fb8858eb21322ef9b506b29a2574442a021539a647921600e29e3154c845a4
Contents?: true
Size: 1.93 KB
Versions: 5
Compression:
Stored size: 1.93 KB
Contents
module Mks module Rate class ServiceBundlesController < ApplicationController before_action :set_service_bundle, only: %i[show update services add_services] before_action :set_bundle_service, only: %i[add_services] def index @service_bundles = ServiceBundle.all render json: @service_bundles end def sdu_bundles result = ServiceBundle.where(service_delivery_unit_id: params[:id]) render json: result end def show render json: @service_bundle end 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 def update if @service_bundle.update(service_bundle_params) render json: @service_bundle else render json: @service_bundle.errors, status: :unprocessable_entity end end def filter search = "%#{params[:search].downcase}%" bundles = ServiceBundle.where('lower(mks_rate_service_bundles.name) LIKE ?', search) render json: bundles end def services render json: @service_bundle.chargeable_services end def add_services result = @service.add_services(@service_bundle, add_services_params[:ids]) render json: { success: result } end private def set_service_bundle @service_bundle = ServiceBundle.find(params[:id]) end def set_bundle_service @service = ServiceBundleService.new end def add_services_params params.permit(ids: []) end def service_bundle_params params.require(:service_bundle).permit(:code, :name, :description, :percent_discount, :service_delivery_unit_id) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems