Class: Workarea::Api::Admin::OrdersController
Instance Method Summary
collapse
#current_user, #sort_direction, #sort_field
Instance Method Details
#index ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'app/controllers/workarea/api/admin/orders_controller.rb', line 78
def index
criteria = Order.all
if params[:email].present?
criteria = criteria.where(email: params[:email])
end
if params[:placed_at_greater_than].present?
criteria = criteria.where(:placed_at.gte => params[:placed_at_greater_than])
end
if params[:placed_at_less_than].present?
criteria = criteria.where(:placed_at.lte => params[:placed_at_less_than])
end
@orders =
criteria
.by_updated_at(starts_at: params[:updated_at_starts_at], ends_at: params[:updated_at_ends_at])
.by_created_at(starts_at: params[:created_at_starts_at], ends_at: params[:created_at_ends_at])
.order_by(sort_field => sort_direction)
.page(params[:page].presence || 1)
respond_with orders: @orders
end
|
#show ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'app/controllers/workarea/api/admin/orders_controller.rb', line 163
def show
@order = Order.find(params[:id])
@payment = Payment.find_or_initialize_by(id: @order.id)
@fulfillment = Fulfillment.find_or_initialize_by(id: @order.id)
@shippings = Shipping.where(order_id: @order.id).to_a
respond_with order: @order,
payment: @payment,
payment_transactions: @payment.transactions,
fulfillment: @fulfillment,
shippings: @shippings
end
|