use of CustomerContracts.ICustomer in project SmartCity-Market by TechnionYP5777.
the class CustomerRegistration_FinalStepScreen method registerButtonPressed.
@FXML
void registerButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
ICustomerProfile iProfile = TempCustomerProfilePassingData.customerProfile;
CustomerProfile profile = new CustomerProfile(iProfile.getUserName(), TempCustomerProfilePassingData.password, iProfile.getFirstName(), iProfile.getLastName(), iProfile.getPhoneNumber(), iProfile.getEmailAddress(), iProfile.getCity(), iProfile.getStreet(), iProfile.getBirthdate(), iProfile.getAllergens(), new ForgotPasswordData(TempCustomerProfilePassingData.sequrityQuestion, TempCustomerProfilePassingData.sequrityAnswer));
try {
customer.registerNewCustomer(profile);
AbstractApplicationScreen.setScene("/CustomerLoginScreen/CustomerLoginScreen.fxml");
TempCustomerProfilePassingData.clear();
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
}
use of CustomerContracts.ICustomer in project SmartCity-Market by TechnionYP5777.
the class CustomerApplicationScreen method start.
@Override
public void start(Stage primaryStage) {
try {
stage = primaryStage;
InjectionFactory.createInjector(new CustomerDiConfigurator());
barcodeEventHandler = InjectionFactory.getInstance(BarcodeEventHandler.class);
barcodeEventHandler.initializeHandler();
barcodeEventHandler.startListening();
setScene("/CustomerWelcomeScreen/CustomerWelcomeScreen.fxml");
stage.setTitle("Smart Market Beta");
stage.setMaximized(true);
stage.setOnCloseRequest(event -> {
try {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
customer.logout();
Platform.exit();
System.exit(0);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
Platform.exit();
System.exit(0);
}
});
stage.show();
} catch (Exception ยข) {
throw new RuntimeException();
}
}
use of CustomerContracts.ICustomer in project SmartCity-Market by TechnionYP5777.
the class CustomerLoginScreen method loginButtonPressed.
@FXML
private void loginButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
try {
if (username.equals(guestLogin.getUserName())) {
DialogMessagesService.showErrorDialog(String.format("The user: \"{0}\" can access only as a guest user.", username), null, "");
return;
}
customer.login(username, password, true);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
} catch (Exception e) {
DialogMessagesService.showErrorDialog(e + "", null, "");
return;
}
TempCustomerPassingData.customer = customer;
AbstractApplicationScreen.setScene("/CustomerMainScreen/CustomerMainScreen.fxml");
}
use of CustomerContracts.ICustomer in project SmartCity-Market by TechnionYP5777.
the class CustomerLoginScreen method guestLoginButtonPressed.
@FXML
private void guestLoginButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
try {
customer.login(guestLogin.getUserName(), guestLogin.getUserName(), true);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
} catch (Exception e) {
DialogMessagesService.showErrorDialog(e + "", null, "");
return;
}
TempCustomerPassingData.customer = customer;
AbstractApplicationScreen.setScene("/CustomerMainScreen/CustomerMainScreen.fxml");
}
use of CustomerContracts.ICustomer in project SmartCity-Market by TechnionYP5777.
the class CustomerRegistration_IngredientsScreen method updateIngredientsCheckList.
private void updateIngredientsCheckList() {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
try {
ingredientsObservableList.addAll(customer.getAllIngredients());
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
ingredientsCheckListView.setItems(ingredientsObservableList);
HashSet<Ingredient> currentAllergans = TempCustomerProfilePassingData.customerProfile.getAllergens();
if (currentAllergans != null && !currentAllergans.isEmpty())
updateListViewWithChosenIngreidients(currentAllergans);
}
Aggregations