public function actionGetOptimalPrice($from, $to, $dateStart, $dateEnd, $forceUpdate)
 {
     try {
         $price = MFlightSearch::getOptimalPrice($from, $to, $dateStart, $dateEnd, $forceUpdate);
         $this->send($price);
         die;
     } catch (Exception $e) {
         $this->sendError(500, $e->getMessage());
     }
 }
 public function run()
 {
     $flightForm = new FlightForm();
     if (isset($_GET['FlightForm'])) {
         $flightForm->attributes = $_GET['FlightForm'];
         if (isset($_GET['RouteForm'])) {
             foreach ($_GET['RouteForm'] as $route) {
                 $newRoute = new RouteForm();
                 $newRoute->attributes = $route;
                 $flightForm->routes[] = $newRoute;
             }
         }
         if ($flightForm->validate()) {
             $result = MFlightSearch::getAllPricesAsJson($flightForm);
             echo $result;
         } else {
             throw new CHttpException(500, CHtml::errorSummary($flightForm));
         }
         Yii::app()->end();
     } else {
         throw new CHttpException(404);
     }
 }