implement registration

This commit is contained in:
Roland Schneider
2018-12-26 16:50:17 +01:00
parent b6e590f196
commit b2bb210cee
18 changed files with 496 additions and 51 deletions

View File

@@ -2,10 +2,13 @@
namespace backend\controllers;
use common\manager\EventRegistrationManager;
use common\models\CardEventRegistrationForm;
use Yii;
use common\models\Event;
use backend\models\EventSearch;
use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@@ -95,6 +98,8 @@ class EventController extends Controller
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws \yii\db\StaleObjectException
*/
public function actionDelete($id)
{
@@ -103,6 +108,31 @@ class EventController extends Controller
return $this->redirect(['index']);
}
public function actionRegisterCard($id){
$model = new CardEventRegistrationForm();
$model->event_id = $id;
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
$manager = new EventRegistrationManager();
try {
$manager->registerCard($model);
} catch (HttpException $e) {
if ( array_key_exists($e->getCode(),EventRegistrationManager::$STATES)) {
$model->addError("id_event", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
} else {
$model->addError("id_event", Yii::t('event-registration', "Unknown Error"));
}
}
}
if ( $model->hasErrors() ){
return $this->redirect(['view', 'id' => $model->registration->id]);
} else {
return $this->render('register_card', [
'model' => $model,
]);
}
}
/**
* Finds the Event model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@@ -2,12 +2,17 @@
namespace backend\controllers;
use common\manager\EventRegistrationManager;
use common\models\CardEventRegistrationForm;
use Yii;
use common\models\EventRegistration;
use backend\models\EventRegistrationSearch;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\ServerErrorHttpException;
/**
* EventRegistrationController implements the CRUD actions for EventRegistration model.
@@ -95,6 +100,8 @@ class EventRegistrationController extends Controller
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws \yii\db\StaleObjectException
*/
public function actionDelete($id)
{
@@ -103,6 +110,29 @@ class EventRegistrationController extends Controller
return $this->redirect(['index']);
}
public function actionRegisterCard(){
$model = new CardEventRegistrationForm();
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
$manager = new EventRegistrationManager();
try {
$manager->registerCard($model);
} catch (HttpException $e) {
if ( array_key_exists($e->getCode(),EventRegistrationManager::$STATES)) {
$model->addError("id_event", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
}else {
$model->addError("id_event", Yii::t('event-registration', "Unknown Error"));
}
}
}
if ( $model->hasErrors() ){
return $this->redirect(['view', 'id' => $model->registration->id]);
} else {
return $this->render('register_card', [
'model' => $model,
]);
}
}
/**
* Finds the EventRegistration model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.