/**
  * @param Newsletter $newsletter
  * @return Newsletter
  */
 public static function create($newsletter)
 {
     // Template
     if (isset($newsletter->templateId) && $newsletter->templateId <= 0) {
         $newsletter->templateId = null;
     }
     // Create Newsletter
     $newsletter->save();
     // Return Newsletter
     return $newsletter;
 }
 public function actionCreate()
 {
     $model = new Newsletter();
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post(), 'Newsletter') && $model->validate()) {
         if (NewsletterService::create($model)) {
             $this->redirect(['all']);
         }
     }
     $templatesMap = TemplateService::getIdNameMapByType(NewsletterGlobal::TYPE_NEWSLETTER, ['default' => true]);
     return $this->render('create', ['model' => $model, 'templatesMap' => $templatesMap]);
 }