Class: Mks::Maintenance::MaintenanceCategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/mks/maintenance/maintenance_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/mks/maintenance/maintenance_categories_controller.rb', line 11

def create
  mc = MaintenanceCategory.new(maintenance_category_params)
  if mc.valid?
    mc.save
    res = Mks::Common::MethodResponse.success_response(mc, 'Maintenance category saved successfully !')
    render json: res
  else
    res = Mks::Common::MethodResponse.failure_response(mc)
    render json: res, status: :unprocessable_entity
  end
end

#indexObject



6
7
8
9
# File 'app/controllers/mks/maintenance/maintenance_categories_controller.rb', line 6

def index
  data = MaintenanceCategory.all
  render json: Mks::Common::MethodResponse.success_response(data)
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/mks/maintenance/maintenance_categories_controller.rb', line 23

def update
  if @maintenance_category.update(maintenance_category_params)
    res = Mks::Common::MethodResponse.success_response(
      @maintenance_category,
      'Maintenance category updated successfully !'
    )
    render json: res
  else
    res = Mks::Common::MethodResponse.failure_response(@maintenance_category)
    render json: res, status: :unprocessable_entity
  end
end