Class: Event::API::V2::Admin::EventsController

Inherits:
BaseController show all
Defined in:
app/controllers/event/api/v2/admin/events_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::ADMIN_ROLES

Instance Method Summary collapse

Methods inherited from BaseController

#authorize_admin!

Methods included from JWTPayload

#email, #jwt_payload, #role, #uid

Methods included from ExceptionHandlers

included

Methods included from Response

#controller_namespace, #error_response, #errors_response, #json_response, #not_found

Instance Method Details

#createObject

POST /admin/events



26
27
28
29
30
31
32
33
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 26

def create
  event = nil
  ActiveRecord::Base.transaction do
    event =Event.create!(events_params)
  end

  json_response(event, 201)
end

#historyObject

GET admin/events/history



36
37
38
39
40
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 36

def history
  event = Event.find(params[:event_id])

  json_response(event.participants, 201)
end

#indexObject

GET /admin/events



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 9

def index
  ransack_params = {
      state_in:       params[:state],
      currency_id_eq: params[:currency_id],
      name_cont_all:  params[:name]
  }

  sales = Event.ransack(ransack_params)
  json_response(paginate(sales.result), 200)
end

#showObject

GET /admin/events/:id



21
22
23
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 21

def show
  json_response(Event.find(params[:id]), 200)
end

#updateObject

PUT /admin/events/:id



43
44
45
46
47
48
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 43

def update
  event = Event.find(params[:id])
  event.update!(events_params)

  json_response(event, 200)
end