class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController

  include AdminHelper
  include OrbitControllerLib::DivisionForDisable

  before_filter :for_app_manager

  def initialize
    super
    @app_title = 'ask_replies'
  end

  def create
    @ask_question = AskQuestion.find(params[:ask_question_id])
    @ask_question.ask_reply = AskReply.new(params[:ask_reply])
    @ask_question.save
    if @ask_question.ask_reply.send_email?
      Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
    end
    redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
  end

  def update
    @ask_reply = AskReply.find(params[:id])
    @ask_reply.update_attributes(params[:ask_reply])
    if @ask_reply.send_email?
      Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
    end
    redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
  end
end
