Search in sources :

Example 1 with ICustomer

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();
    }
}
Also used : ICustomer(CustomerContracts.ICustomer) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ICustomerProfile(BasicCommonClasses.ICustomerProfile) ICustomerProfile(BasicCommonClasses.ICustomerProfile) CustomerProfile(BasicCommonClasses.CustomerProfile) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 2 with ICustomer

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();
    }
}
Also used : BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) CustomerDiConfigurator(CustomerDI.CustomerDiConfigurator) ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException)

Example 3 with ICustomer

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");
}
Also used : ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 4 with ICustomer

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");
}
Also used : ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 5 with ICustomer

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);
}
Also used : Ingredient(BasicCommonClasses.Ingredient) ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException)

Aggregations

ICustomer (CustomerContracts.ICustomer)5 SMException (SMExceptions.SMException)5 FXML (javafx.fxml.FXML)3 CustomerProfile (BasicCommonClasses.CustomerProfile)1 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 ICustomerProfile (BasicCommonClasses.ICustomerProfile)1 Ingredient (BasicCommonClasses.Ingredient)1 CustomerDiConfigurator (CustomerDI.CustomerDiConfigurator)1 BarcodeEventHandler (UtilsImplementations.BarcodeEventHandler)1