Example #1
0
        private async void SubmitButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textConfigURL.Text))
            {
                Utils.Utils.ShowToast(this, "Enter Server Url.");
            }
            else
            {
                string domain = textConfigURL.Text;
                PreferenceHandler.SetDomainKey(domain);
                InvokeApi.SetDomainUrl(domain);
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.SetTitle("Loading...");
                dialog.Show();
                var response = await InvokeApi.Invoke(Constants.API_GET_MOBILE_CONFIGURATION, string.Empty, HttpMethod.Get);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(strContent);
                    dialog.Dismiss();
                    if (string.IsNullOrEmpty(config.B2cAuthorizeURL) || string.IsNullOrEmpty(config.B2cChangePasswordPolicy) || string.IsNullOrEmpty(config.B2cChangePasswordURL) || string.IsNullOrEmpty(config.B2cClientId) ||
                        string.IsNullOrEmpty(config.B2cClientSecret) || string.IsNullOrEmpty(config.B2cRedirectUrl) || string.IsNullOrEmpty(config.B2cSignInPolicy) || string.IsNullOrEmpty(config.B2cSignUpPolicy) ||
                        string.IsNullOrEmpty(config.B2cTenant) || string.IsNullOrEmpty(config.B2cTokenURL) || string.IsNullOrEmpty(config.B2cTokenURLIOS))
                    {
                        Utils.Utils.ShowToast(this, "Invalid Configuration details");
                    }
                    else
                    {
                        B2CConfigManager.GetInstance().Initialize(config);
                        PreferenceHandler.SetConfig(strContent);
                        Intent intent = new Intent(Application.Context, typeof(LoginActivity));
                        StartActivity(intent);
                        Finish();
                    }
                }
                else
                {
                    Utils.Utils.ShowToast(this, response.ReasonPhrase);
                    dialog.Dismiss();
                }
            }
        }
Example #2
0
        private async void ButtonSubmit_TouchUpInside(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextFieldConfig.Text))
            {
                IOSUtil.ShowMessage("Enter Domain Url.", null, this);
            }
            else
            {
                string domain = TextFieldConfig.Text;
                PreferenceHandler.SetDomainKey(domain);
                InvokeApi.SetDomainUrl(domain);
                var response = await InvokeApi.Invoke(Constants.API_GET_MOBILE_CONFIGURATION, string.Empty, HttpMethod.Get);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(strContent);
                    if (string.IsNullOrEmpty(config.B2cAuthorizeURL) || string.IsNullOrEmpty(config.B2cChangePasswordPolicy) || string.IsNullOrEmpty(config.B2cChangePasswordURL) || string.IsNullOrEmpty(config.B2cClientId) ||
                        string.IsNullOrEmpty(config.B2cClientSecret) || string.IsNullOrEmpty(config.B2cRedirectUrl) || string.IsNullOrEmpty(config.B2cSignInPolicy) || string.IsNullOrEmpty(config.B2cSignUpPolicy) ||
                        string.IsNullOrEmpty(config.B2cTenant) || string.IsNullOrEmpty(config.B2cTokenURL) || string.IsNullOrEmpty(config.B2cTokenURLIOS))
                    {
                        IOSUtil.ShowMessage("Invalid Configuration details", null, this);
                        PreferenceHandler.SetDomainKey(string.Empty);
                    }
                    else
                    {
                        B2CConfigManager.GetInstance().Initialize(config);
                        PreferenceHandler.SetConfig(strContent);
                        var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");
                        NavController.PushViewController(ViewController, false);
                    }
                }
                else
                {
                    IOSUtil.ShowMessage(response.ReasonPhrase, null, this);
                    PreferenceHandler.SetDomainKey(string.Empty);
                }
            }
        }