Class: Logistics::Core::OperationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::OperationsController
- Defined in:
- app/controllers/logistics/core/operations_controller.rb
Instance Method Summary collapse
- #assign ⇒ Object
- #assigned ⇒ Object
- #create ⇒ Object
- #filter_fresh_by_client ⇒ Object
- #fresh ⇒ Object
- #index ⇒ Object
- #unassigned ⇒ Object
- #update ⇒ Object
Instance Method Details
#assign ⇒ Object
69 70 71 72 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 69 def assign response = @service.assign_owner(assign_params[:payload]) render json: response end |
#assigned ⇒ Object
55 56 57 58 59 60 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 55 def assigned operations = Operation.where.not(owner_id: nil) data = ApplicationRecord.as_json(operations) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 18 def create service = OperationService.new result, @operation = service.save(model_params) if result response = Mks::Common::MethodResponse.new(true, 'Operation saved successfully!', @operation, nil, nil) else errors = Mks::Common::Util. @operation, 'Operation' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#filter_fresh_by_client ⇒ Object
48 49 50 51 52 53 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 48 def filter_fresh_by_client operations = Operation.joins(:offer_request).fresh.where('logistics_core_offer_requests.client_id = ?', params[:id]) data = ApplicationRecord.as_json(operations) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#fresh ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 41 def fresh operations = Operation.fresh data = ApplicationRecord.as_json(operations) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 7 def index operations = Operation.includes(:declarant, :declaration_type, :transport_mode, :customs_office, :customs_office_unit, :country_of_origin, :acquisition_mode, :payment_term, :delivery_term, :container_arrangement, :customs_transport_tariff, :esl_transport_tariff, :warehouse, :owner, :offer_request).order('id DESC') data = ApplicationRecord.as_json(operations) response = { success: true, data: data } render json: response end |
#unassigned ⇒ Object
62 63 64 65 66 67 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 62 def unassigned operations = Operation.where(owner_id: nil) data = ApplicationRecord.as_json(operations) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/logistics/core/operations_controller.rb', line 30 def update operation = Operation.find(params[:id]) update_attributes(operation, model_params) if operation.save response = Mks::Common::MethodResponse.new(true, 'Operation updated successfully!', nil, nil, nil) else response = Mks::Common::MethodResponse.new(false, nil, nil, ['Operation update failed!'], nil) end render json: response end |