Beispiel #1
0
  public Collection<Order> findAllByConsumer() {
    Collection<Order> result;
    Consumer consu;

    consu = consumerService.findByPrincipal();

    Assert.notNull(consu);

    result = orderRepository.findAllByConsumerId(consu.getId());

    return result;
  }
Beispiel #2
0
    @Override
    protected Boolean doInBackground(Void... parameters) {

      if (isCancelled()) return null;

      try {

        String response = "";

        Map<String, String> params = new HashMap<String, String>();

        response = ConsumerService.getInstance().login(mUsuario, mPassword);
        JSONObject o = new JSONObject(response);
        int retorno = Integer.parseInt(o.get("retorno").toString());

        // Senha invalida:
        if (retorno < 0) {
          return false;
        }

        idMotorista = Integer.parseInt(o.get("id_motorista").toString());
        nomeMotorista = o.get("nome").toString();

        getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
            .edit()
            .putString(PREF_USERNAME, mUsuario)
            .putString(PREF_PASSWORD, mPassword)
            .putString(PREF_ID, o.get("id_motorista").toString())
            .commit();

        dados = ConsumerService.getInstance().buscaDadosEntregas(String.valueOf(idMotorista));

      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return true;
    }
Beispiel #3
0
  // req: 16.1
  public void cancelOrder(Order order) {
    Assert.notNull(order);
    Assert.isTrue(order.getId() != 0);
    Assert.isTrue(
        order.getConsumer().equals(consumerService.findByPrincipal()),
        "Only the owner can cancel the order");
    Assert.isTrue(order.getCancelMoment() == null, "order.cancel.error.isCancelled");
    Clerk clerk;

    clerk = clerkService.findByOrder(order);

    Assert.isNull(clerk, "Can't remove a order when a clerk has assigned");

    order.setCancelMoment(new Date());
    this.save(order);
  }