Sha256: bc998f7ef28fc580b2a6710592c3dae24b544f0c86ac03686136f501f6a9e21e

Contents?: true

Size: 1.09 KB

Versions: 14

Compression:

Stored size: 1.09 KB

Contents

module Comee
  module Core
    class CustomerOrderItemsController < ApplicationController
      include Common

      def cancel
        CustomerOrderItem.where(id: params[:ids]).update_all(canceled: true)
        render json: {success: true}
      end

      def filter
        data = CustomerOrderItem.includes(:product, :unit).ransack(params[:q]).result
        render_content(data)
      end

      def destroy
        item = CustomerOrderItem.find(params[:id])

        if item.customer_order.draft?
          item.destroy
          render json: {success: true}
        else
          render json: {success: false, error: "Customer order should be in draft state."}, status: :forbidden
        end
      end

      private

      def model_params
        params.require(:payload)
              .permit(
                :customer_item_no,
                :quantity,
                :price,
                :total_price,
                :delivery_date,
                :canceled,
                :product_id,
                :customer_order_id,
                :unit_id
              )
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
comee_core-0.2.10 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.9 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.8 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.7 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.6 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.5 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.4 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.3 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.2 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.1 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.2.0 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.1.99 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.1.98 app/controllers/comee/core/customer_order_items_controller.rb
comee_core-0.1.97 app/controllers/comee/core/customer_order_items_controller.rb