Class: Mks::Edm::LocationTypesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

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 = Mks::Common::MethodResponse.failure_response(lt)
    render json: res, status: :unprocessable_entity
  end
end

#indexObject



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

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

#updateObject



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

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