public function unassignAggregatorAction()
 {
     if (!$this->getRequest()->isPost()) {
         throw new AppEx\UnexpectedException("Resquest must be POST");
     }
     $data = $this->_helper->requestData();
     $cgId = $data['cgId'];
     if (!isset($cgId) && !strlen($cgId)) {
         throw new AppEx\InvalidArgumentException('You must indicate a commercial group id');
     }
     $commercialGroup = $this->_cgSrv->load($cgId);
     //GLOBALPORTAL-34278
     //TODO: very hacky approach don't like it
     $commercialGroupData = $commercialGroup->exportData();
     $commercialGroupData = $this->_cgSrv->cleanDataForUpdate($commercialGroupData);
     $commercialGroupData = $this->_cgSrv->clearDataForUpdate($commercialGroupData);
     $commercialGroup->importData($commercialGroupData);
     if (empty($commercialGroup)) {
         throw new NotFoundException("Commercial Group {$cgId} not found", 404);
     }
     // Check permissions
     $this->_helper->allowed('unassign_aggregator', $commercialGroup);
     $result = $this->_cgSrv->unassignAggregator($commercialGroup);
     // Response with the organization id
     $this->view->data = $result;
 }
 /**
  * Update an user identified by its Id
  */
 public function putAction()
 {
     $commercialGroup = $this->_getCommercialGroup();
     // Check permissions
     $this->_helper->allowed('update', $commercialGroup);
     // Check data
     $data = $this->_helper->requestData(true, false);
     if (empty($data)) {
         return;
     }
     if (isset($data['endCustomer']) && $data['endCustomer'] === '-') {
         $data['endCustomer'] = "";
     }
     $data = $this->_mapToModel($data);
     // CleaN
     $data = $this->_cgSrv->cleanDataForUpdate($data);
     // CleaR
     $data = $this->_cgSrv->clearDataForUpdate($data);
     $data = $this->_helper->filter($data)->blacklist(array('customerId'));
     $commercialGroup = $commercialGroup->importData($data);
     try {
         $this->_cgSrv->update($commercialGroup);
     } catch (\Application\Model\Mapper\Exception\EricssonException $e) {
         if ($e->getCode() == 40133) {
             \App::log()->err($e->getMessage());
             throw new InvalidArgumentException("Invalid parameter value: billingAccountId");
         } else {
             throw $e;
         }
     } catch (\Application\Exceptions\ValidateException $e) {
         throw $this->_mapException($e);
     }
     $this->getResponse()->setHttpResponseCode(204);
     $this->_helper->viewRenderer->setNoRender(TRUE);
 }
 /**
  * Update an user identified by its Id
  */
 public function putAction()
 {
     $id = $this->_getParam('id', null);
     if (!isset($id) && !strlen($id)) {
         throw new InvalidArgumentException('You must indicate a commercial group id');
     }
     $commercialGroup = $this->_cgSrv->load($id);
     // Check permissions
     $this->_helper->allowed('update', $commercialGroup);
     if (empty($commercialGroup)) {
         throw new NotFoundException("Commercial Group {$id} not found", 404);
     }
     $data = $this->_helper->requestData();
     $data = $this->_cgSrv->cleanDataForUpdate($data);
     $data = $this->_cgSrv->clearDataForUpdate($data);
     $commercialGroup->importData($data);
     $result = $this->_cgSrv->update($commercialGroup);
     // Response with the organization id
     $this->view->data = $result;
 }