Пример #1
0
  public void save(ContentValues data) {
    long id = 0;
    String code = data.getAsString("code");
    Customer c = new Customer();

    if (_repo.getByCode(code) != null) {
      c = _repo.getByCode(code);
      id = c.getId();
    }

    c.setName(data.getAsString("name"));
    c.setCode(data.getAsString("code"));
    c.setAddress(data.getAsString("address"));
    c.setVatNumber(data.getAsString("iva"));
    c.setProv(data.getAsString("prov"));
    c.setCity(data.getAsString("city"));
    c.setTelephone(data.getAsString("tel"));
    c.setCap(data.getAsString("cap"));

    if (id > 0) {
      _repo.edit(c);
    } else {
      _repo.add(c);
    }
  }
Пример #2
0
  public void saveAll(Iterable<ContentValues> data) {
    ArrayList<Customer> customers = new ArrayList<>();

    for (ContentValues cv : data) {
      Customer c = new Customer();
      c.setName(cv.getAsString("name"));
      c.setCode(cv.getAsString("code"));
      c.setAddress(cv.getAsString("address"));
      c.setVatNumber(cv.getAsString("iva"));
      c.setProv(cv.getAsString("prov"));
      c.setCity(cv.getAsString("city"));
      c.setTelephone(cv.getAsString("tel"));
      c.setCap(cv.getAsString("cap"));

      customers.add(c);
    }

    _repo.addAll(customers);
  }