public function actionUpdate($id)
    {
        if (!empty($id)) {
            $model = Currency::findOne($id);
        }
        else {
            $model = new Currency();
        }

        if (Yii::$app->request->isPost) {
            if ($model->load(Yii::$app->request->post())) {

                if ($model->validate()) {
                    $model->save();
                }
                return $this->redirect(\Yii::$app->request->referrer);
            }
            else {
                throw new Exception();
            }
        }
        return $this->render('update', [
            'model' => $model
        ]);
    }