import org.mxchange.jcustomercore.model.customer.Customer;
import org.mxchange.jcustomercore.model.customer.status.CustomerAccountStatus;
import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaAdminWebRequestController;
import org.mxchange.pizzaapplication.model.customer.PizzaAdminCustomerSessionBeanRemote;
/**
*/
private PizzaAdminCustomerSessionBeanRemote adminCustomerBean;
+ /**
+ * Admin helper instance
+ */
+ @Inject
+ private PizzaAdminWebRequestController adminHelper;
+
/**
* An event being fired when an administrator has added a new customer
*/
@Override
public String addCustomer () {
// Are at least some fields added?
- if (!this.isCustomerDataSet()) {
+ if ((this.adminHelper.getContact() == null) && (!this.isCustomerDataSet())) {
// Not all customer data is set
throw new FaceletException("Please provide minimum personal data: gender, first_name, family_name"); //NOI18N
}
- // Get contact instance
- Contact contact = this.adminContactController.createContactInstance();
+ // Init contact
+ Contact contact;
+
+ // Is the contact set in helper?
+ if (this.adminHelper.getContact() instanceof Contact) {
+ // Get from helper
+ contact = this.adminHelper.getContact();
+ } else {
+ // Get new contact instance
+ contact = this.adminContactController.createContactInstance();
+ }
// Ask the EJB for a free customer number
String customerNumber = this.adminCustomerBean.createCustomerNumber();