Пример #1
0
 public OTPVerificationPage(OTPResponse ObjOTPResponseModel)
 {
     InitializeComponent();
     _objOTPResponseModel             = ObjOTPResponseModel;
     _objOTPVerificationResponseModel = new OTPVerificationResponseModel();
     _apiServices = new RestApi();
     _baseUrl     = Settings.Url + Domain.OTPVerificationApiConstant;
     NavigationPage.SetHasNavigationBar(this, false);
     otpDescTxt.Text        = "we have sent you an OTP to" + " " + Settings.PhoneNo + " " + "Please enter the same here!";
     entryoOtpNo.Completed += (sender, e) =>
     {
         btnOtpSubmit_Clicked(sender, e);
     };
 }
Пример #2
0
        public async Task <OTPVerificationResponseModel> OTPAsync(string uri, Boolean IsHeaderRequired, HeaderModel objHeaderModel, OTPResponse _objOTPResponseModel)
        {
            // client.MaxResponseContentBufferSize = 256000;
            OTPVerificationResponseModel _objOTPVerificationResponseModel = new OTPVerificationResponseModel();

            var keyValues = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("OTP", _objOTPResponseModel.OTP.ToString()),
                new KeyValuePair <string, string>("UserId", _objOTPResponseModel.UserId.ToString())
            };

            if (IsHeaderRequired)
            {
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Length", "69");
                client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Fiddler");
                client.DefaultRequestHeaders.TryAddWithoutValidation("Host", "localhost:49165");
            }
            var request = new HttpRequestMessage(HttpMethod.Post, uri);

            request.Content = new FormUrlEncodedContent(keyValues);

            HttpResponseMessage response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var SucessResponse = await response.Content.ReadAsStringAsync();

                _objOTPVerificationResponseModel = JsonConvert.DeserializeObject <OTPVerificationResponseModel>(SucessResponse);
                return(_objOTPVerificationResponseModel);
            }
            else
            {
                var ErrorResponse = await response.Content.ReadAsStringAsync();

                //  ErrorResponse = ErrorResponse.Insert(1, "\"Status\"" + _col + "\"Fail\",");
                _objOTPVerificationResponseModel = JsonConvert.DeserializeObject <OTPVerificationResponseModel>(ErrorResponse);
                return(_objOTPVerificationResponseModel);
            }
        }
Пример #3
0
        private async void btnOtpSubmit_Clicked(object sender, EventArgs e)
        {
            try
            {
                var otptxt = entryoOtpNo.Text;
                _objOTPResponseModel.OTP = Convert.ToInt32(otptxt);
                if (string.IsNullOrEmpty(otptxt))
                {
                    DependencyService.Get <IToast>().ShowToast("Please Entr 4 digit OTP here!");
                }
                else
                {
                    await Navigation.PushPopupAsync(new LoadingPopPage());

                    _objOTPVerificationResponseModel = await _apiServices.OTPAsync(new Get_API_Url().OTPApi(_baseUrl), false, new HeaderModel(), _objOTPResponseModel);

                    var Result = _objOTPVerificationResponseModel.Response;
                    if (Result.StatusCode == 200)
                    {
                        if (Result.DOB != null)
                        {
                            DateTime dts = Convert.ToDateTime(Result.DOB.ToString());
                            //DateTime date = Convert.ToDateTime(dts, CultureInfo.InvariantCulture);
                            //DateTime dt = DateTime.Parse(dts,  CultureInfo.InvariantCulture);
                            string dateOfBirth = dts.ToString("dd MMM yyyy", CultureInfo.InvariantCulture);
                            Settings.DOB = dateOfBirth;
                        }
                        else
                        {
                            Settings.DOB = Result.DOB.ToString();
                        }
                        // Settings.UserName = Result.UserName;
                        Settings.Name           = Result.Name;
                        Settings.Id             = Result.Id;
                        Settings.ProfilePicture = Result.ProfilePicture;
                        //"https://media.licdn.com/mpr/mpr/shrinknp_200_200/AAEAAQAAAAAAAAV7AAAAJDZjNjkwZDg4LTEyMjktNGJjYy05ZjIyLWE5M2VhMjJkNDE2ZA.jpg"; //"http://www.pathlab360.com/images/doctor-single.jpg"; //
                        Settings.Address    = Result.Address;
                        Settings.RoleId     = Result.RoleId;
                        Settings.TokenCode  = Result.TokenCode;
                        Settings.UserPin    = Result.UserPin;
                        Settings.PhoneNo    = Result.PhoneNo;
                        Settings.Gender     = Result.Gender;
                        Settings.Email      = Result.Email;
                        Settings.IsLoggedIn = true;

                        // DependencyService.Get<IPushNotificationRegister>().ExtractTokenAndRegister();
                        // DependencyService.Get<IToast>().ShowToast(Result.Message);
                        var otherPage = new MenuPage();
                        var homePage  = App.NavigationPage.Navigation.NavigationStack.First();
                        App.NavigationPage.Navigation.InsertPageBefore(otherPage, homePage);
                        await App.NavigationPage.PopToRootAsync(false);

                        await Navigation.PopAllPopupAsync();
                    }
                    else
                    {
                        DependencyService.Get <IToast>().ShowToast(Result.Message);
                        await Navigation.PopAllPopupAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <IToast>().ShowToast("Something Went Wrong please try Again or check your Internet Connection!!");
                await Navigation.PopAllPopupAsync();

                var msg = ex.Message;
            }
        }