/**
  * Allows the user to make changes to an existing vendor
  * 
  * If data has been posted, an attempt will be made to save the changes to the database.  The user
  * will then be redirected to the vendor view with a notification whether the changes were saved
  * or not.  If no data has been posted, the method will attempt to render a form with the editable
  * fields for the vendor indicated via ID in the query string.  If no ID is given in the query string
  * or if a vendor matching that ID cannot be found in the database, the user will be redirected to the
  * vendor index.
  */
 public function actionEdit()
 {
     if (isset($_POST['model'])) {
         $model = vendors::model()->getByPK($_POST['model']['id']);
         $model->setAttributes($_POST['model']);
         if ($model->save()) {
             testProject::setAlert('The changes were saved successfully.', 'success');
         } else {
             testProject::setAlert('We\'re sorry but your changes were not saved.  Please try again.', 'danger');
         }
         $this->redirect('vendors/view/' . $model->id);
     } else {
         if (isset($_GET['value'])) {
             $model = vendors::model()->getByPK($_GET['value']);
             $this->render('edit', array('model' => $model));
         } else {
             $this->redirect('vendors/index');
         }
     }
 }
 /**
  * Deletes a category
  * 
  * If no category ID is passed or if it does not match a valid product ID in the database, an error
  * message is generated.  Otherwise the category is deleted and a success message is generated.  In either
  * case the user is redirected to the categories index.
  */
 public function actionDelete()
 {
     testProject::setAlert('There was a problem with your request.  Please try again.', 'error');
     if (isset($_GET['value'])) {
         $model = categories::model()->getByPK($_GET['value']);
         $name = $model->name;
         if ($model->delete()) {
             testProject::setAlert('The item ' . $name . ' was deleted.', 'info');
         }
     }
     $this->redirect('categories/index');
 }
 /**
  * Deletes a product
  * 
  * If no product ID is passed or if it does not match a valid product ID in the database, an error
  * message is generated.  Otherwise the product is deleted and a success message is generated.  In either
  * case the user is redirected to the products index.
  */
 public function actionDelete()
 {
     testProject::setAlert('There was a problem with your request.  Please try again.', 'error');
     if (isset($_GET['value'])) {
         //check if ID is provided
         $model = products::model()->getByPK($_GET['value']);
         $name = $model->name;
         if ($model->delete()) {
             //attempt to delete the item
             testProject::setAlert('The item ' . $name . ' was deleted.', 'info');
         }
     }
     $this->redirect('products/index');
 }