Class: Logistics::Core::DeclarationTypesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::DeclarationTypesController
- Defined in:
- app/controllers/logistics/core/declaration_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/logistics/core/declaration_types_controller.rb', line 21 def create @declaration_type = DeclarationType.new(declaration_type_params) if @declaration_type.save response = Mks::Common::MethodResponse.new(true, 'Declaration type saved successfully!', @declaration_type, nil, nil) else errors = Mks::Common::Util. @declaration_type, 'Declaration type' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#filter_by_transaction_type ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/controllers/logistics/core/declaration_types_controller.rb', line 13 def filter_by_transaction_type declaration_types = DeclarationType.includes(:transaction_type) .where(transaction_type_id: params[:id]) data = ApplicationRecord.as_json(declaration_types) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/logistics/core/declaration_types_controller.rb', line 6 def index declaration_types = DeclarationType.includes(:transaction_type) data = ApplicationRecord.as_json(declaration_types) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/logistics/core/declaration_types_controller.rb', line 32 def update if @declaration_type.update(declaration_type_params) response = Mks::Common::MethodResponse.new(true, "Declaration type updated successfully!", @declaration_type, nil, nil) else errors = Mks::Common::Util. @declaration_type, "Declaration type" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |