Can Not Redirect To Page

I am new to YII framework.

Whenever user delete any record then I do not want to delete record physically from database but add "END DATE" field to NOW() value to the record which are going to delete. I have add following code to the controller, it put current datetime to the enddate field but not redirect to the admin page.

public function actionDelete($id)




	// Check if  product type is connected with other module

		$aCheckDeptEmp = array();

		$aCheckLink = Products::model()->findAll('ptype=:pt', array(':pt'=>$id));

		if(count($aCheckLink) > 0) {

			Yii::app()->user->setFlash('record_linked','PRODUCT TYPE linked with product(s)');

		} else {

			// add current datetime top enddate(edt) field of record


			$model->edt = date("Y-m-d H:i:s");


[size="5"]//now I want to redirect to view/product/admin page[/size]

			//$this->loadModel($id)->delete();// i dont wan this to delete physically


	// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser


		$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));



		throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');


For redirect you can use


(as a few lines below in your code)

notice: to count products you can use statistical query.