Sha256: 42a5f903d10aba3fad48d576a5be66483beac33f0b688dd2e0a8027088e9bc49

Contents?: true

Size: 1.43 KB

Versions: 9

Compression:

Stored size: 1.43 KB

Contents

require_dependency "application_controller"

module Logistics
  module Core
    class StandardRemarksController < ApplicationController
      before_action :set_standard_remark, only: [:update]
      def index
        standard_remarks = StandardRemark.all
        render json: Mks::Common::MethodResponse.new(true, nil, standard_remarks, nil, nil)
      end

      def create
        standard_remark = StandardRemark.new(standard_remark_params)
        if standard_remark.save
          res = Mks::Common::MethodResponse.new(true, 'Remark added successfully !', nil, nil, nil)
        else
          errors = Mks::Common::Util.error_messages('Standard Remark', standard_remark)
          res = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: res
      end

      def update
        if @standard_remark.update(standard_remark_params)
          res = Mks::Common::MethodResponse.new(true, 'Remark updated successfully !', nil, nil, nil)
        else
          errors = Mks::Common::Util.error_messages(@standard_remark, 'Standard Remark')
          res = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
        end
        render json: res
      end

      private
      def standard_remark_params
        params.require(:standard_remark).permit(:id, :code, :description)
      end

      def set_standard_remark
        @standard_remark = StandardRemark.find(params[:id])
      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/standard_remarks_controller.rb
logistics_core-21.11.1 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-21.08.1 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-21.03.1 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-20.10.3 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-20.10.2 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-20.10.1 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-20.9.1 app/controllers/logistics/core/standard_remarks_controller.rb
logistics_core-20.8.1 app/controllers/logistics/core/standard_remarks_controller.rb