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); } }
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)); } }
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']); } }
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']); } } }