class Fixxperts::ExpertSessionsController

Public Instance Methods

confirm() click to toggle source

Confirm the request for expert session.

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 50
def confirm
  expert_session = current_user.expert_sessions.find(params[:id])
  unless expert_session.confirmed?
    unless expert_session.confirm!(params[:message])
      return redirect_via_turbolinks_to dashboard_path, alert: "Could not confirm Appointment. Cannot charge card."
    end
    ExpertSessionsMailer.delay(queue: :mailer).confirmed_email_customer(expert_session)
    redirect_via_turbolinks_to dashboard_path, notice: "Session Confirmed"
  else
    redirect_via_turbolinks_to dashboard_path, alert: "This session has already been confirmed by you."
  end
end
create() click to toggle source

Create expert session.

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 22
def create
  @expert_session = @fixxpert.expert_sessions.new(expert_session_params)
  respond_to do |format|
    format.js do
      if save!
        render 'create'
      else
        render partial: 'expert_sessions/form', locals: {expert_session: @expert_session}, replace: 'form#new_expert_session'
      end
    end
  end
end
new() click to toggle source

Intitalize the object for new expert session.

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 7
def new
  if params[:start_time] and params[:end_time]
    @expert_session = @fixxpert.expert_sessions.new(start_time: params[:start_time], end_time: params[:end_time], date: params[:start_time].to_date)
  else
    @expert_session = @fixxpert.expert_sessions.new(expert_session_params)
  end
  @expert_session.attachments.build unless @expert_session.attachments.exists?
  if params[:resource_type]
    @expert_session.resource_id = params[:resource_id]
    @expert_session.resource_type = params[:resource_type]
  end
  render layout: false
end
reject() click to toggle source

reject the request for expert session.

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 64
def reject
  expert_session = current_user.expert_sessions.find(params[:id])
  unless expert_session.rejected?
    if expert_session.reject!(params[:message] , current_user)
      notice = "Session cancelled"
    else
      notice = "Could not cancell this session."
    end
    redirect_via_turbolinks_to dashboard_path, notice: notice
  else
    redirect_via_turbolinks_to dashboard_path, alert: "This Session is already in rejected state."
  end
end
respond() click to toggle source

To find expert session of current user

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 43
def respond
  @fixxpert = current_user
  @expert_session = @fixxpert.expert_sessions.find(params[:id])
  render layout: false
end
show() click to toggle source

Retrieves all expert sessions for current fixxpert.

# File app/controllers/fixxperts/expert_sessions_controller.rb, line 36
def show
  @fixxpert = current_user
  @expert_session = @fixxpert.expert_sessions.find(params[:id])
  @invoice = @expert_session.invoice
end