<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Teilnehmer\BayerischerApothekertagStudenten\HandleAnmeldung;

class HandleAnmeldungController extends \Kufer\KuferTools\Basis\Controller\ToolController
{
  protected function getUseCase(): \Kufer\KuferTools\Basis\UseCase\UseCase
  {
    return new HandleAnmeldungUseCase(
      $this->getRequestObj()
    );
  }

  protected function getRequestObj()
  {
    $requestObj = new HandleAnmeldungRequest();
    $requestObj->knrs = explode(':', \PostOperations::getVarValue('knrs'));
    $requestObj->zahlart = \PostOperations::getVarValue('anm_zahlart');
    $requestObj->guthaben_verwenden = \GetOperations::isDefined('guthaben_verwenden');
    $requestObj->abwBankverbindungAngegeben = \PostOperations::isDefined('abw_iban');
    $requestObj->abw_isNurFuerAnmeldung = \PostOperations::getVarValue('abw_isNurFuerAnmeldung', false) === 'true';
    $requestObj->abw_verfahren = \PostOperations::getVarValue('abw_verfahren');
    $requestObj->abw_inhaber = \PostOperations::getVarValue('abw_inhaber');
    $requestObj->abw_bank = \PostOperations::getVarValue('abw_bank');
    $requestObj->abw_kto = \PostOperations::getVarValue('abw_kto');
    $requestObj->abw_kto = \PostOperations::getVarValue('abw_kto');
    $requestObj->abw_blz = \PostOperations::getVarValue('abw_blz');
    $requestObj->abw_bic = \PostOperations::getVarValue('abw_bic');
    $requestObj->abw_iban = \PostOperations::getVarValue('abw_iban');
    $requestObj->anzWeitereTn = \PostOperations::getVarValue('anm_anz_weitere_tn', 0);

    return $this->handleXsrf($requestObj, 'handleAnmeldungApotagStudenten');
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return new HandleAnmeldungPresenter($pUseCaseResponse);
  }
}