Class: Mks::Maintenance::LocationTypesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mks/maintenance/location_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  lt = LocationType.new(location_type_params)
  if lt.valid?
    lt.save
    res = Mks::Common::MethodResponse.success_response(lt, 'Location type saved successfully !')
    render json: res
  else
    res = failure_response(lt)
    render json: res, status: :unprocessable_entity
  end
end

#indexObject



5
6
7
8
# File 'app/controllers/mks/maintenance/location_types_controller.rb', line 5

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

#updateObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/mks/maintenance/location_types_controller.rb', line 22

def update
  if @lt.update(location_type_params)
    res = Mks::Common::MethodResponse.success_response(@lt, 'Location type updated successfully !')
    render json: res
  else
    res = failure_response(@lt)
    render json: res, status: :unprocessable_entity
  end
end