Exemple #1
0
 /**
  * POST Index action.
  *
  * @return void
  */
 public function post_index()
 {
     $this->get_index();
     $validator = Validation_Seller::update();
     if (!$validator->run()) {
         Session::set_alert('error', __('form.error'));
         $this->view->errors = $validator->error();
         return;
     }
     $data = $validator->validated();
     if (!Service_Seller::update(Seller::active(), $data)) {
         Session::set_alert('error', 'There was an error updating the seller.');
         return;
     }
     Session::set_alert('success', 'The seller has been updated.');
 }
Exemple #2
0
 /**
  * Updates a seller.
  *
  * @param int $id Seller ID.
  *
  * @return void
  */
 public function put_index($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $seller = \Service_Seller::find_one($id);
     if (!$seller || $seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     $validator = \Validation_Seller::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $seller = \Service_Seller::update($seller, $data);
     if (!$seller) {
         throw new HttpServerErrorException();
     }
     $this->response($seller);
 }