/**
  * Create a new user
  */
 public function postAction()
 {
     $data = $this->_helper->requestData(true);
     // Avoid setting custom id
     $data = $this->_helper->filter($data)->blacklist(array('id'));
     if (empty($data['customerId'])) {
         $data['customerId'] = \App::getUserLogged()->getOrganizationId();
     }
     $commercialGroup = new CommercialGroupModel($data);
     // Check if it's allowed
     $this->_helper->allowed('create', $commercialGroup);
     $data = $this->_mapToModel($data);
     // Check mandatory fields
     //         $this->_preValidate($data, new CommercialGroupValidate());
     $commercialGroup = new CommercialGroupModel($data);
     // Create the organization via its service
     try {
         $this->_cgSrv->create($commercialGroup);
     } catch (ValidateException $ex) {
         throw $this->_mapException($ex);
     }
     $url = $this->getFrontController()->getRouter()->assemble(array('controller' => $this->getRequest()->getControllerName(), 'action' => $this->getRequest()->getActionName(), 'id' => $commercialGroup->getId()));
     $this->getResponse()->setHeader('Location', $url);
     $this->getResponse()->setHttpResponseCode(201);
 }
 /**
  * Create a new user
  */
 public function postAction()
 {
     // Avoid setting custom id
     $data = $this->_helper->requestData(true);
     $data = $this->_helper->filter($data)->blacklist(array('id'));
     if (empty($data['customerId'])) {
         $data['customerId'] = \App::getUserLogged()->getOrganizationId();
     }
     $commercialGroup = new CommercialGroupModel($data);
     // Check if it's allowed
     $this->_helper->allowed('create', $commercialGroup);
     // Create the organization via its service
     $this->_cgSrv->create($commercialGroup);
     // Response with the organization id
     $this->view->data = $commercialGroup->getId();
 }