async Task AddToCardsList()
        {
            ErrorBucket errors = new ErrorBucket();
            ValidateAddCard(errors);

            if (!(errors.HasErrors))
            {   //create string and add to list
                string cardstring = string.Format("{0}*{1}*{2}*{3}", Bank, CardNo, Expiry, CVV);
                Cards.Add(cardstring);
                Bank = string.Empty;
                CardNo = string.Empty;
                ExpiryMonth = string.Empty;
                ExpiryYear = string.Empty;
                CVV = string.Empty;
                Bank = string.Empty;

                // save as array
                if (Cards.Count > 0)
                {
                    ApplicationData.Current.LocalSettings.Values["Cards"] = Cards.ToArray();
                    AddCardNo = res.GetString("AddCard/Text") + "[" + Cards.Count + "]";
                }
            }
            else
            {
                await UIHelper.ShowAlert(errors.GetErrorsAsString());
            }

        }
        private async Task DoRegister()
        {
            ErrorBucket errors = new ErrorBucket();

            IsBusy = true;
            // validate...
            ValidateSignUp(errors);

            // ok?
            if (!(errors.HasErrors))
            {
                if (UIHelper.HasInternetConnection())
                {
                    await RegisterAsync();
                }
                else
                {
                    await UIHelper.ShowAlert(res.GetString("NoInternet"));
                }
            }

            // errors?
            if (errors.HasErrors)
            {
                await UIHelper.ShowAlert(errors.GetErrorsAsString());
            }

            IsBusy = false;
        }
        //login
        private async Task DoLogin()
        {
            ErrorBucket errors = new ErrorBucket();

            IsBusy = true;

            Validate(errors);

            // ok?
            if (!(errors.HasErrors))
            {
                //check internet
                if (UIHelper.HasInternetConnection())
                {
                    await LoginAsync();
                }
                else
                {
                    await UIHelper.ShowAlert(res.GetString("NoInternet"));
                }
            }
            // errors?
            if (errors.HasErrors)
            {
                await UIHelper.ShowAlert(errors.GetErrorsAsString());

                errors.ClearErrors();
            }

            IsBusy = false;
        }
        private void menuSave_Click(object sender, EventArgs e)
        {
            ErrorBucket errors = new ErrorBucket();
            string name = this.textName.Text.Trim();
            if (string.IsNullOrEmpty(name))
                errors.Add("Name is required.");
            string url = this.textUrl.Text.Trim();
            if (string.IsNullOrEmpty(url))
                errors.Add("URL is required.");

            // ok...
            if (!(errors.HasErrors))
            {
                // set...
                this.Bookmark.Name = name;
                this.Bookmark.Url = url;
                this.Bookmark.IsLocalModified = true;
                this.Bookmark.IsLocalDeleted = false;

                // save...
                this.Bookmark.SaveChanges();

                // finish...
                this.DialogResult = DialogResult.OK;
            }

            // show...
            if (errors.HasErrors)
                Alert.Show(errors.GetAllErrorsSeparatedByCrLf());
        }
Esempio n. 5
0
        private async Task HandleSaveAsync()
        {
            // validate...
            var errors = new ErrorBucket();

            if (string.IsNullOrEmpty(this.Item.Name))
            {
                errors.AddError("Name is required.");
            }
            if (this.SelectedStream == null)
            {
                errors.AddError("Stream is required.");
            }

            // if...
            if (!(errors.HasErrors))
            {
                // set...
                this.Item.StreamId = this.SelectedStream.Id;

                // save...
                await this.Item.SaveChangesAsync();

                // back...
                this.Host.GoBack();
            }
            else
            {
                await this.Host.ShowMessageAsync(errors);
            }
        }
        //validate login
        private void Validate(ErrorBucket errors)
        {
            if (string.IsNullOrEmpty(Phone) || Phone.Length < 12)
            {
                errors.AddError(res.GetString("InvalidPhone"));
            }


            //if (string.IsNullOrEmpty(Password) || Password.Length < 6)
            //    errors.AddError(res.GetString("ValidPassword"));
        }
        private ErrorBucket AssureBucket(string prop)
        {
            ErrorBucket bucket;

            if (!Errors.TryGetValue(prop, out bucket))
            {
                bucket = new ErrorBucket();
                Errors.Add(prop, bucket);
            }
            return(bucket);
        }
        //validate AddCard
        private void ValidateAddCards(ErrorBucket errors)
        {
            if (Cards.Count() < 1)
                errors.AddError(res.GetString("NeedCard"));

            if (string.IsNullOrEmpty(Phone) || Phone.Length < 12)
                errors.AddError(res.GetString("InvalidPhone"));

            if (string.IsNullOrEmpty(Code))
                errors.AddError(res.GetString("RequiredCode"));

        }
        //validate register
        private void ValidateSignUp(ErrorBucket errors)
        {
            if (string.IsNullOrEmpty(BusinessName))
            {
                errors.AddError(res.GetString("RequiredBusinessName"));
            }

            if (string.IsNullOrEmpty(Email))
            {
                errors.AddError(res.GetString("RequiredEmail"));
            }

            if (string.IsNullOrEmpty(VerifyEmail))
            {
                errors.AddError(res.GetString("RequiredEmail"));
            }

            if (!(string.IsNullOrEmpty(Email)) && Email != VerifyEmail && !(string.IsNullOrEmpty(VerifyEmail)))
            {
                errors.AddError(res.GetString("MatchEmail"));
            }

            if (string.IsNullOrEmpty(Phone) || Phone.Length < 12)
            {
                errors.AddError(res.GetString("InvalidPhone"));
            }

            if (string.IsNullOrEmpty(Code))
            {
                errors.AddError(res.GetString("RequiredCode"));
            }

            if (string.IsNullOrEmpty(Password))
            {
                errors.AddError(res.GetString("RequiredPassword"));
            }

            if (string.IsNullOrEmpty(Confirm))
            {
                errors.AddError(res.GetString("ConfirmPassword/Text"));
            }

            if (!(string.IsNullOrEmpty(Password)) && Password.Length < 6)
            {
                errors.AddError(res.GetString("ValidPassword"));
            }

            // check the PINs...
            if (!(string.IsNullOrEmpty(Password)) && Password != Confirm && !(string.IsNullOrEmpty(Confirm)))
            {
                errors.AddError(res.GetString("MatchPassword"));
            }
        }
        private void ValidateAddCard(ErrorBucket errors)
        {
            if (string.IsNullOrEmpty(Bank))
                errors.AddError(res.GetString("RequiredBank"));

            if (string.IsNullOrEmpty(CardNo))
                errors.AddError(res.GetString("RequiredCardNo"));

            if (string.IsNullOrEmpty(Expiry))
                errors.AddError(res.GetString("RequiredExpiry"));

            if (string.IsNullOrEmpty(CVV.ToString()))
                errors.AddError(res.GetString("RequiredCVV"));

        }
Esempio n. 11
0
        //validate AddUser
        private void ValidateSignUp(ErrorBucket errors)
        {
            if (string.IsNullOrEmpty(FirstName))
            {
                errors.AddError(res.GetString("RequiredFirstName"));
            }

            if (string.IsNullOrEmpty(LastName))
            {
                errors.AddError(res.GetString("RequiredLastName"));
            }

            if (string.IsNullOrEmpty(IdNo))
            {
                errors.AddError(res.GetString("RequiredID"));
            }

            if (string.IsNullOrEmpty(Phone) || Phone.Length < 12)
            {
                errors.AddError(res.GetString("InvalidPhone"));
            }

            if (string.IsNullOrEmpty(Code))
            {
                errors.AddError(res.GetString("RequiredCode"));
            }

            if (string.IsNullOrEmpty(PIN))
            {
                errors.AddError(res.GetString("RequiredPIN"));
            }

            if (string.IsNullOrEmpty(Confirm))
            {
                errors.AddError(res.GetString("VerifyPin/Text"));
            }

            if (!(string.IsNullOrEmpty(PIN)) && PIN.Length < 4)
            {
                errors.AddError(res.GetString("ValidPIN"));
            }

            // check the PINs...
            if (!(string.IsNullOrEmpty(PIN)) && PIN != Confirm && !(string.IsNullOrEmpty(PIN)))
            {
                errors.AddError(res.GetString("MatchPIN"));
            }
        }
Esempio n. 12
0
        //validate Generate
        private void ValidateGenerate(ErrorBucket errors)
        {
            if (string.IsNullOrEmpty(Phone) || Phone.Length < 12)
            {
                errors.AddError(res.GetString("InvalidPhone"));
            }

            if (string.IsNullOrEmpty(Pin))
            {
                errors.AddError(res.GetString("RequiredPIN"));
            }

            if (!string.IsNullOrEmpty(Pin) && Pin.Length < 4)
            {
                errors.AddError(res.GetString("ValidPIN"));
            }
        }
        private async Task AddCard()
        {

            ErrorBucket errors = new ErrorBucket();
            IsBusy = true;
            // validate...
            ValidateAddCards(errors);

            // ok?
            if (!(errors.HasErrors))
            {
                if (UIHelper.HasInternetConnection())
                    await AddCardAsync();
                else
                    await UIHelper.ShowAlert(res.GetString("NoInternet"));
            }

            // errors?
            if (errors.HasErrors)
                await UIHelper.ShowAlert(errors.GetErrorsAsString());

            IsBusy = false;

        }
        private void DoLogon()
        {
            // validate...
            ErrorBucket bucket = new ErrorBucket();
            string username = this.textUsername.Text.Trim();
            if (string.IsNullOrEmpty(username))
                bucket.Add("Username is required.");
            string password = this.textPassword.Text.Trim();
            if (string.IsNullOrEmpty(password))
                bucket.Add("Password is required.");

            // error?
            if (bucket.HasErrors)
            {
                Alert.Show(bucket.GetAllErrorsSeparatedByCrLf());
                return;
            }

            // clear the credentials...
            this.ClearCredentials();

            // logon...
            UsersService users = new UsersService();
            users.Logon(username, password, delegate(LogonResponse response)
            {
                // we managed to get a response...
                if (response.Result == LogonResult.LogonOk)
                {
                    // we did it...
                    this.LogonOk();
                }
                else
                    Alert.Show(response.Message);

            }, Alert.GetFailedHandler());
        }
 internal static Task ShowAlertAsync(this Page page, ErrorBucket errors)
 {
     return ShowAlertAsync(page, errors.GetErrorsAsString());
 }
Esempio n. 16
0
 internal GetMaidResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 public IAsyncOperation<Windows.UI.Popups.IUICommand> ShowAlertAsync(ErrorBucket errors)
 {
     return null;
 }
 Task IViewModelHost.ShowAlertAsync(ErrorBucket errors)
 {
     return PageExtender.ShowAlertAsync(this, errors).AsTask();
 }
 internal RegisterResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
Esempio n. 20
0
 public Task ShowMessageAsync(ErrorBucket bucket)
 {
     return(this.ShowMessageAsync(bucket.GetErrorsAsString()));
 }
 internal ConfirmPaymentResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
Esempio n. 22
0
 internal static Task ShowAlertAsync(this Page page, ErrorBucket errors)
 {
     return(ShowAlertAsync(page, errors.GetErrorsAsString()));
 }
 internal VerifyResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
        private async Task AddCardAsync()
        {
            await UIHelper.ToggleProgressBar(true, res.GetString("Loading"));
            CardItem cardItem = new CardItem();
            cardItem.Phone = Phone;
            cardItem.Code = Code;
            List<string> bankslst = new List<string>();
            List<string> cardslst = new List<string>();
            List<string> expiryslst = new List<string>();
            List<string> cvvslst = new List<string>();

            for (int i = 0; i < Cards.Count(); i++)
            {
                string[] cardArray = Cards[i].Split('*');
                bankslst.Add(cardArray[0]);
                cardslst.Add(cardArray[1]);
                expiryslst.Add(cardArray[2]);
                cvvslst.Add(cardArray[3]);
            }
            cardItem.BankArray = bankslst;
            cardItem.CardArray = cardslst;
            cardItem.ExpiryArray = expiryslst;
            cardItem.CVVArray = cvvslst;
            cardItem.NumberOfCards = Cards.Count();

            string jsonstr = JsonConvert.SerializeObject(cardItem);
            Debug.WriteLine(jsonstr);

            var MyResult = await Rest.PostAsync("users/add-card", jsonstr);
            statuscode = MyResult.Key;
            output = MyResult.Value;

            if (statuscode == HttpStatusCode.OK)
            {
                if ((string)output["status"] != "error")
                {
                    if (ApplicationData.Current.LocalSettings.Values.ContainsKey("Cards"))
                        ApplicationData.Current.LocalSettings.Values.Remove("Cards");
                    _navigationService.NavigateTo("QR",Phone);
                }
                else
                {
                    await UIHelper.ShowAlert((string)output["error"]["message"][0]);
                }
            }
            else if (statuscode.ToString() == "422" )
            {
                JArray banksArray = (JArray)output["error"]["message"];
                ErrorBucket errors = new ErrorBucket();
                List<string> lsterrors = banksArray.Select(c => (string)c).ToList();
                foreach (var item in lsterrors)
                    errors.AddError(item);
                if(lsterrors.Count() == 1 && lsterrors[0] == "Invalid verification code")
                {
                    await UIHelper.ShowAlert(errors.GetErrorsAsString());
                }
                else
                {
                    _navigationService.NavigateTo("ManageCard");
                    await UIHelper.ShowAlert(errors.GetErrorsAsString());
                }

            }
            else if(statuscode == HttpStatusCode.Unauthorized)
            {                
            }
            else
            {
                await UIHelper.ShowAlert((string)output["error"]["message"][0]);
            }
            await UIHelper.ToggleProgressBar(false);
            input.Clear();
        }
Esempio n. 25
0
 internal TaskCompleteResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 IAsyncOperation<IUICommand> IViewModelHost.ShowAlertAsync(ErrorBucket errors)
 {
     return PageExtender.ShowAlertAsync(this, errors);
 }
Esempio n. 27
0
 internal static IAsyncOperation <IUICommand> ShowAlertAsync(this Page page, ErrorBucket errors)
 {
     return(ShowAlertAsync(page, errors.GetErrorsAsString()));
 }
 internal static IAsyncOperation<IUICommand> ShowAlertAsync(this Page page, ErrorBucket errors)
 {
     return ShowAlertAsync(page, errors.GetErrorsAsString());
 }
 internal NewPassResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
Esempio n. 30
0
 void IViewModelHost.ShowAlertAsync(ErrorBucket errors)
 {
     this.ShowAlertAsync(errors);
 }
 public Task ShowAlertAsync(ErrorBucket errors)
 {
     return(null);
 }
        private void buttonSaveChanges_Click(object sender, RoutedEventArgs e)
        {
            ErrorBucket errors = new ErrorBucket();
            string name = this.textName.Text.Trim();
            if (string.IsNullOrEmpty(name))
                errors.Add("Name is required.");
            string url = this.textUrl.Text.Trim();
            if (string.IsNullOrEmpty(url))
                errors.Add("URL is required.");

            // ok?
            if(!(errors.HasErrors))
            {
                // set...
                if (Bookmark == null)
                    throw new InvalidOperationException("'Bookmark' is null.");
                this.Bookmark.Name = name;
                this.Bookmark.Url = url;

                // set...
                this.Bookmark.IsLocalModified = true;
                this.Bookmark.IsLocalDeleted = false;

                // save...
                this.Bookmark.SaveChanges();

                // back...
                NavigationService.Navigate(new Uri("/ConfigurePage.xaml", UriKind.RelativeOrAbsolute));
            }

            // show...
            if(errors.HasErrors)
                Alert.Show(this, errors.GetAllErrorsSeparatedByCrLf());
        }
Esempio n. 33
0
 Task IViewModelHost.ShowAlertAsync(ErrorBucket errors)
 {
     return(PageExtender.ShowAlertAsync(this, errors).AsTask());
 }
Esempio n. 34
0
 internal UpdateLocationResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 IAsyncOperation <IUICommand> IViewModelHost.ShowAlertAsync(ErrorBucket errors)
 {
     return(PageExtender.ShowAlertAsync(this, errors));
 }
 internal SignOutResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 internal GetProfileResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 public Task ShowAlertAsync(ErrorBucket errors)
 {
     return null;
 }
Esempio n. 39
0
 internal EvaluateResult(ErrorBucket bucket)
     : base(bucket)
 {
 }
 public Task ShowAlertAsync(ErrorBucket errors)
 {
     // log and defer...
     this.NumErrorBucketMessages++;
     return this.ShowAlertAsync(errors.GetErrorsAsString());
 }