Class: Workarea::Api::Admin::DiscountsController
Instance Method Summary
collapse
#current_user, #sort_direction, #sort_field
Instance Method Details
#create ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'app/controllers/workarea/api/admin/discounts_controller.rb', line 106
def create
attrs = params[:discount].presence || {}
@discount = NewDiscount.new_discount(attrs[:type], attrs.except(:type))
@discount.save!
respond_with(
{ discount: @discount },
{ status: :created,
location: discount_path(@discount) }
)
end
|
#destroy ⇒ Object
258
259
260
261
|
# File 'app/controllers/workarea/api/admin/discounts_controller.rb', line 258
def destroy
@discount.destroy
head :no_content
end
|
#index ⇒ Object
97
98
99
100
101
102
103
104
|
# File 'app/controllers/workarea/api/admin/discounts_controller.rb', line 97
def index
@discounts = Pricing::Discount
.all
.order_by(sort_field => sort_direction)
.page(params[:page])
respond_with discounts: @discounts
end
|
#show ⇒ Object
249
250
251
|
# File 'app/controllers/workarea/api/admin/discounts_controller.rb', line 249
def show
respond_with discount: @discount
end
|
#update ⇒ Object
253
254
255
256
|
# File 'app/controllers/workarea/api/admin/discounts_controller.rb', line 253
def update
@discount.update_attributes!(params[:discount])
respond_with discount: @discount
end
|