コード例 #1
0
        private async void CreateClicked(object obj)
        {
            if (Email == null || SelectedDay == null || Phone == null || SelectedMonth == null || SelectedCategory == null)
            {
                await _dialogService.ShowDialog(
                    "All fields are required",
                    "Account Create Error",
                    "OK");
            }
            else
            {
                try
                {
                    _dialogService.ShowLoading("Creating...");
                    string birthDay      = SelectedDay;
                    string birthMonth    = SelectedMonth;
                    int    categoryId    = SelectedCategory.Id;
                    string customerEmail = Email;
                    string customerPhone = Phone;
                    string marketerEmail = _settingsService.UserNameSetting;
                    var    result        = await _customerDataService.RegisterNewCustomerByMarketer(customerEmail, customerPhone, birthDay, birthMonth, categoryId, marketerEmail);

                    _dialogService.HideLoading();
                    if (result != null)
                    {
                        _dialogService.ShowToast("Customer account has been created successfully.");
                        var navServ = App.ViewNavigationService;
                        CustomersListPageModel clp = new CustomersListPageModel();
                        clp.LoadData();
                        await navServ.GoBack();
                    }
                    else
                    {
                        await _dialogService.ShowDialog("Customer account was not created. Try with another email, or contact Support.", "Error", "Cancel");
                    }
                }
                catch (System.Exception)
                {
                    _dialogService.HideLoading();
                    await _dialogService.ShowDialog(
                        "This username/password combination is not valid",
                        "Error logging you in",
                        "OK");
                }
            }
        }