add customer api for order reservation
This commit is contained in:
34
app/controllers/api/order_reservation_controller.rb
Normal file
34
app/controllers/api/order_reservation_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
class Api::OrderReservationController < Api::ApiController
|
||||||
|
skip_before_action :authenticate
|
||||||
|
|
||||||
|
def check_customer
|
||||||
|
customer_name = params[:name]
|
||||||
|
customer_email = params[:email]
|
||||||
|
customer_contact_no = params[:contact_no]
|
||||||
|
customer_gender = params[:gender]
|
||||||
|
customer_addr = params[:address]
|
||||||
|
customer_membership_id = params[:membership_id]
|
||||||
|
customer_membership_type = params[:membership_type]
|
||||||
|
customer_date_of_birth = params[:date_of_birth]
|
||||||
|
customer_id = 0
|
||||||
|
|
||||||
|
check_customer = Customer.find_by_email_and_contact_no_and_membership_id_and_membership_type(customer_email,customer_contact_no,customer_membership_id,customer_membership_type)
|
||||||
|
if !check_customer.nil?
|
||||||
|
customer_id = check_customer.customer_id
|
||||||
|
else
|
||||||
|
customer = Customer.new
|
||||||
|
customer.name = customer_name
|
||||||
|
customer.email = customer_email
|
||||||
|
customer.contact_no = customer_contact_no
|
||||||
|
customer.gender = customer_gender
|
||||||
|
customer.address = customer_addr
|
||||||
|
customer.date_of_birth = Time.parse(customer_date_of_birth).strftime("%Y-%m-%d")
|
||||||
|
customer.membership_id = customer_membership_id
|
||||||
|
customer.membership_type = customer_membership_type
|
||||||
|
customer.save!
|
||||||
|
customer_id = customer.id
|
||||||
|
end
|
||||||
|
|
||||||
|
render :json => { :status => true, :data => { customer_id : customer_id} }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -82,7 +82,10 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
post "survey/:id" => "survey#create"
|
post "survey/:id" => "survey#create"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#order and reservation api
|
||||||
|
namespace :order_reservation do
|
||||||
|
post "customer" => "order_reservation#check_customer"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Cashier ------------#
|
#--------- Cashier ------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user