Beispiel #1
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     if (Yii::app()->request->isAjaxRequest) {
         $proxy = new BProduct();
         $result = $proxy->deleteProduct($id);
         echo CJSON::encode($result);
     }
 }
Beispiel #2
0
 public function run()
 {
     $start = Yii::app()->request->getParam('start');
     $proxy = new BProduct();
     $result = $proxy->getProductList($start, 10);
     $count = $result['count'];
     if (Yii::app()->request->isAjaxRequest) {
         $data = array('recordsTotal' => $count, 'recordsFiltered' => $count, 'data' => $result['data']);
         echo CJSON::encode($data);
     } else {
         $this->controller->render('list', array('count' => $count));
     }
 }
Beispiel #3
0
 public function run()
 {
     $name = Yii::app()->request->getParam('name');
     $price = Yii::app()->request->getParam('price');
     $times = Yii::app()->request->getParam('times');
     $number = Yii::app()->request->getParam('number');
     $data = array('name' => $name, 'price' => $price, 'times' => $times, 'number' => $number);
     $proxy = new BProduct();
     $result = $proxy->createProduct($data);
     if ($result['code'] == 200) {
         $this->controller->redirect('/route/list');
     } else {
         throw new CHttpException($result['code'], $result['message']);
     }
 }
Beispiel #4
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $name = Yii::app()->request->getParam('name');
     $price = Yii::app()->request->getParam('price');
     $times = Yii::app()->request->getParam('times');
     $number = Yii::app()->request->getParam('number');
     $data = array('name' => $name, 'price' => $price, 'times' => $times, 'number' => $number);
     $proxy = new BProduct();
     if (Yii::app()->request->isAjaxRequest) {
         $result = $proxy->updateProduct($data, $id);
         echo CJSON::encode($result);
     } else {
         $result = $proxy->getProductInfo($id);
         if ($result['code'] == 200) {
             $this->controller->render('editproduct', array('data' => $result['data']));
         } else {
             throw new CHttpException($result['code'], $result['message']);
         }
     }
 }