Пример #1
0
        async partial void NextButtonClicked(Foundation.NSObject sender)
        {
            View.EndEditing(true);

            string emailAddress = (string)Transporter.SharedInstance.GetObjectForKey("email");
            string code         = VerificationCodeTextField.Text.Trim();

            bool allFieldsValid = ValidateAllFields();

            if (!allFieldsValid)
            {
                return;
            }

            ShowHud(Strings.Hud.please_wait);

            try
            {
                var result = await WebServices.EmailController.UseValidationCode(emailAddress, code);

                if (result.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var outlet = new Outlet();
                    outlet.Handle = emailAddress;
                    outlet.Type   = Outlet.outlet_type_email;
                    outlet.Name   = emailAddress;

                    var outletSaved = RealmServices.SaveOutlet(outlet);
                    if (outletSaved)
                    {
                        var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                        NavigationController.PopToViewController(popToViewController, true);
                    }
                    else
                    {
                        ShowDuplicateEntryAlert();
                    }
                }
                else
                {
                    VerificationCodeTextField.SetInvalid();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            HideHud();
        }
Пример #2
0
        protected override bool ValidateAllFields()
        {
            string code = VerificationCodeTextField.Text.Trim();

            bool allFieldsValid = true;

            if (String.IsNullOrEmpty(code))
            {
                VerificationCodeTextField.SetInvalid();
                allFieldsValid = false;
            }

            return(allFieldsValid);
        }
        async partial void NextButtonClicked(Foundation.NSObject sender)
        {
            View.EndEditing(true);

            string code = StringUtils.RemoveNonIntegers(VerificationCodeTextField.Text.Trim());

            bool allFieldsValid = ValidateAllFields();

            if (!allFieldsValid)
            {
                return;
            }

            ShowHud(Strings.Hud.please_wait);

            try
            {
                var result = await TwilioServices.VerifyPhoneAsync(PhoneNumber, code);

                if (result != null && result.success)
                {
                    var outlet = new Outlet();
                    outlet.Handle = PhoneNumber;
                    outlet.Type   = Outlet.outlet_type_phone;
                    outlet.Name   = PhoneNumber;

                    var outletSaved = RealmServices.SaveOutlet(outlet);
                    if (outletSaved)
                    {
                        var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First();
                        NavigationController.PopToViewController(popToViewController, true);
                    }
                    else
                    {
                        ShowDuplicateEntryAlert();
                    }
                }
                else
                {
                    VerificationCodeTextField.SetInvalid();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            HideHud();
        }