Class: Logistics::Core::OperationDocumentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Logistics::Core::OperationDocumentsController
- Defined in:
- app/controllers/logistics/core/operation_documents_controller.rb
Instance Method Summary collapse
- #accept ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #download ⇒ Object
- #index ⇒ Object
- #update ⇒ Object
Instance Method Details
#accept ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 34 def accept document = OperationDocument.find(params[:id]) document.is_accepted = true document.user_id = params[:user_id] document.date_accepted = DateTime.now.to_date document.save response = Mks::Common::MethodResponse.new(true, "Operation document accepted!", document, nil, nil) render json: response end |
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 13 def create @operation_document = OperationDocument.new(operation_document_params) if @operation_document.save response = Mks::Common::MethodResponse.new(true, 'Operation document saved successfully!', @operation_document, nil, nil) else errors = Mks::Common::Util. @operation_document, 'Operation document' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |
#destroy ⇒ Object
49 50 51 52 53 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 49 def destroy @operation_document.destroy response = Mks::Common::MethodResponse.new(true, "Operation document deleted!", nil, nil, nil) render json: response end |
#download ⇒ Object
44 45 46 47 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 44 def download document = OperationDocument.find(params[:id]) render json: Base64.encode64(document.file.read) end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 6 def index operation_documents = OperationDocument.where(:operation_id => params[:id]) data = ApplicationRecord.as_json(operation_documents) response = Mks::Common::MethodResponse.new(true, nil, data, nil, nil) render json: response end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/logistics/core/operation_documents_controller.rb', line 24 def update if @operation_document.update(operation_document_params) response = Mks::Common::MethodResponse.new(true, "Operation document updated successfully!", @operation_document, nil, nil) else errors = Mks::Common::Util. @operation_document, "Operation document" response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) end render json: response end |