Commit e59873db authored by Nicolas Svirchevsky's avatar Nicolas Svirchevsky

Uploading edited customer

parent e86c8367
......@@ -77,4 +77,15 @@ public class CustomerData extends AbstractJsonDataSavable {
createdCustomers = (List<Customer>) objs.get(1);
resolvedIds = (HashMap<String, String>) objs.get(2);
}
public void update(Customer oldCustomer, Customer newCustomer) {
if (oldCustomer.getId().equals(newCustomer.getId())) {
if (this.createdCustomers.contains(oldCustomer)) {
this.createdCustomers.remove(oldCustomer);
}
this.customers.remove(oldCustomer);
this.createdCustomers.add(newCustomer);
this.customers.add(newCustomer);
}
}
}
......@@ -204,6 +204,7 @@ public class CustomerInfoDialog extends DialogFragment
/**
* recursive function to get a ascendant order of Ticket.
*
* @param it
*/
private void addATicketToHistoryData(Iterator<Receipt> it) {
......@@ -279,16 +280,21 @@ public class CustomerInfoDialog extends DialogFragment
} else {
customer = createCustomer();
}
if (customer != null) {
send(customer);
}
} catch (NotConformException ignore){
send(customer);
} catch (NotConformException ignore) {
}
}
private Customer editCustomer() throws NotConformException {
throw new NotConformException();
Customer customer = createCustomer();
this.updateCustomer(customer);
return this.mCustomer;
}
private void updateCustomer(Customer newCustomer) {
Data.Customer.update(this.mCustomer, newCustomer);
this.mCustomer = newCustomer;
}
private void send(Customer customer) {
......@@ -322,12 +328,11 @@ public class CustomerInfoDialog extends DialogFragment
} else {
//noinspection UnnecessaryLocalVariable
String dispName = lastNameStr;
Customer c = new Customer(null, dispName, "",
return new Customer(null, dispName, "",
firstNameStr, lastNameStr, address1Str,
address2Str, zipCodeStr, cityStr, departmentStr,
countryStr, mailStr, phone1Str, phone2Str, faxStr,
0.0, 0.0, 0.0, "0", noteStr);
return c;
}
throw new NotConformException();
}
......@@ -523,7 +528,7 @@ public class CustomerInfoDialog extends DialogFragment
b.show();
}
}
private class NotConformException extends Throwable {
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment