//public async void loadISO() //{ // try // { //var result = await CommonLib.GetISO(CommonLib.ws_MainUrl + "getCountries"); //if (result.status == 1) //{ // countryTxt.ItemsSource = result.data.countries; // countryTxt.SelectedIndex = 1; // load(); // } // } // catch (Exception ex) // { // } //} private async void Btn_Clicked(object sender, EventArgs e) { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } var returnMessage = CheckValidations(); if (!string.IsNullOrEmpty(returnMessage)) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(returnMessage)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } try { LoggedInUser obj = App.Database.GetLoggedInUser(); await Navigation.PushPopupAsync(new Loader()); string postData = "first_name=" + fNameTxt.Text + "&last_name=" + lNameTxt.Text + "&password="******"&email=" + emailTxt.Text + "&phone=" + phoneNumberTxt.Text + "&country_code=" + phoneCodePicker.SelectedItem + "&deviceType=" + "&deviceToken=" + "&userType=" + obj.userType + "&id=" + obj.userId + "&surname=" + surnameTxt.Text + "&streetaddress=" + streetaddressTxt.Text + "&city=" + cityTxt.Text + "&state=" + stateTxt.Text + "&country=" + countryISO + "&postcode=" + postcodeTxt.Text; HttpClient httpClient = new HttpClient(); string boundary = "---8d0f01e6b3b5dafaaadaad"; MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary); try { var fileContent = new ByteArrayContent(mysfile); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "image", FileName = "userimage" + ".png", }; multipartContent.Add(fileContent); } catch { } HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "registerUser?" + postData, multipartContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content != null) { mysfile = null; UserResult objData = new UserResult(); objData = Newtonsoft.Json.JsonConvert.DeserializeObject <UserResult>(content); if (objData.status == 1) { Loader.CloseAllPopup(); // Save data in sqlite for login check LoggedInUser objUser = new LoggedInUser(); objUser.ID = obj.ID; objUser.userId = Convert.ToInt32(objData.data.User.id); objUser.fname = objData.data.User.first_name; objUser.lname = objData.data.User.last_name; objUser.email = objData.data.User.email; objUser.image = CommonLib.img_MainUrl + objData.data.User.image; objUser.phone = objData.data.User.phone; objUser.userType = objData.data.User.userType; objUser.country_code = objData.data.User.country_code; objUser.is_shop = objData.data.User.is_shop; objUser.surName = objData.data.User.surname; objUser.streetAddress = objData.data.User.streetaddress; objUser.city = objData.data.User.city; objUser.state = objData.data.User.state; objUser.country = objData.data.User.country; objUser.postCode = objData.data.User.postcode; App.Database.SaveLoggedInUser(objUser); if (App.Lng == "ar-AE") { await DisplayAlert("", objData.msg_ar, "OK"); } else { await DisplayAlert("", objData.msg_en, "OK"); } if (obj.userType == "1") { App.Current.MainPage = new NavigationPage(new MainPage()); } else { App.Current.MainPage = new NavigationPage(new HomeMasterPage()); } } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } } else { Loader.CloseAllPopup(); await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage("Try again")); await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
private async void Pay_Clicked(object sender, EventArgs e) { if (paymentType == "2") { string products = ""; var _note = AddNotePage.notes; try { products = "["; var _products = App.Database.GetAllProduct(); List <CartProductDetail> cartProductDetails = new List <CartProductDetail>(); cartProductDetails.Clear(); foreach (var group in _products) { var resultID = cartProductDetails.Find(x => x.baseProductId == group.baseProductId); if (resultID == null) { products += "{"; products += '"' + "id" + '"' + ":" + group.baseProductId + ","; products += '"' + "addon" + '"' + ":" + "["; cartProductDetails.Add(new CartProductDetail { baseProductId = group.baseProductId }); foreach (var food in _products) { if (group.baseProductId == food.baseProductId) { int type = 1; if (food.typePrice == "M") { type = 1; } if (food.typePrice == "L") { type = 2; } if (food.typePrice == "S") { type = 3; } products += "{"; products += '"' + "id" + '"' + ":" + food.productId + ","; products += '"' + "quantity" + '"' + ":" + food.productQty + ","; products += '"' + "note" + '"' + ":" + '"' + food.note + '"' + ","; products += '"' + "type" + '"' + ":" + type; products += "},"; } } products = products.Substring(0, products.Length - 1); products += "]"; products += "},"; } } products = products.Substring(0, products.Length - 1); products += "]"; } catch (Exception) { } string note_Json = ""; if (AddNotePage.notes.Count > 0) { try { note_Json = "["; foreach (var cn in _note) { //id note_Json += "{"; note_Json += '"' + "shop_id" + '"' + ":" + cn.id + ","; note_Json += '"' + "description" + '"' + ":" + '"' + cn.noteTxt + '"'; note_Json += "},"; } note_Json = note_Json.Substring(0, note_Json.Length - 1); note_Json += "]"; } catch (Exception) { } } var ans = await App.Current.MainPage.DisplayAlert("", AppResources.createOrder, AppResources.yes, AppResources.no); if (ans) { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "user_id=" + objUser.userId + "&items=" + products + "&payment_method=" + paymentType + "&full_address=" + DeliveryAddressPopUp.Txt + "&lat=" + DeliveryAddressPopUp.Lat1 + "&lng=" + DeliveryAddressPopUp.Lng1 + "¬es=" + note_Json + "&self_pick=" + pickOrders; HttpClient httpClient = new HttpClient(); string boundary = "---8d0f01e6b3b5dafaaadaad"; MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary); try { foreach (var cn in _note) { if (cn.noteImg != null) { var fileContent = new ByteArrayContent(cn.noteImg); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "note_image[]", FileName = cn.id + "_orderNote" + ".png", }; multipartContent.Add(fileContent); } else { string fileName = "Icon"; byte[] array = Encoding.ASCII.GetBytes(fileName); var fileContent = new ByteArrayContent(array); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "note_image[]", FileName = cn.id + "_emptyNote" + ".png", }; multipartContent.Add(fileContent); } } } catch { } HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "createOrder?" + postData, multipartContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content != null) { CreateOrderResult objData = new CreateOrderResult(); objData = Newtonsoft.Json.JsonConvert.DeserializeObject <CreateOrderResult>(content); if (objData.status == 1) { PaymentPopUp.checkoitId = objData.data.checkout_id; //notes clear // AddNotePage.notes.Clear(); // App.Database.ClearProduc(); // App.Database.ClearAddon(); Loader.CloseAllPopup(); PaymentPopUp Popup = new PaymentPopUp(); await App.Current.MainPage.Navigation.PushPopupAsync(Popup); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } } else { Loader.CloseAllPopup(); await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(response.ReasonPhrase.ToString())); await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } } else { string products = ""; var _note = AddNotePage.notes; try { products = "["; var _products = App.Database.GetAllProduct(); List <CartProductDetail> cartProductDetails = new List <CartProductDetail>(); cartProductDetails.Clear(); foreach (var group in _products) { var resultID = cartProductDetails.Find(x => x.baseProductId == group.baseProductId); if (resultID == null) { products += "{"; products += '"' + "id" + '"' + ":" + group.baseProductId + ","; // products += '"' + "quantity" + '"' + ":" + group.productQty + ","; products += '"' + "addon" + '"' + ":" + "["; // var _addons = App.Database.GetAllProductAddon(Convert.ToString(group.ID)); cartProductDetails.Add(new CartProductDetail { baseProductId = group.baseProductId }); foreach (var food in _products) { if (group.baseProductId == food.baseProductId) { int type = 1; if (food.typePrice == "M") { type = 1; } if (food.typePrice == "L") { type = 2; } if (food.typePrice == "S") { type = 3; } products += "{"; products += '"' + "id" + '"' + ":" + food.productId + ","; products += '"' + "quantity" + '"' + ":" + food.productQty + ","; products += '"' + "note" + '"' + ":" + '"' + food.note + '"' + ","; products += '"' + "type" + '"' + ":" + type; products += "},"; } } // //if (_addons.Count != 0) products = products.Substring(0, products.Length - 1); products += "]"; products += "},"; } } // products = products.Substring(0, products.Length - 1); products += "]"; } catch (Exception) { } string note_Json = ""; if (AddNotePage.notes.Count > 0) { try { note_Json = "["; foreach (var cn in _note) { note_Json += "{"; note_Json += '"' + "shop_id" + '"' + ":" + cn.id + ","; note_Json += '"' + "description" + '"' + ":" + '"' + cn.noteTxt + '"'; note_Json += "},"; } note_Json = note_Json.Substring(0, note_Json.Length - 1); note_Json += "]"; } catch (Exception) { } } var ans = await App.Current.MainPage.DisplayAlert("", AppResources.createOrder, AppResources.yes, AppResources.no); if (ans) { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "user_id=" + objUser.userId + "&items=" + products + "&payment_method=" + paymentType + "&full_address=" + DeliveryAddressPopUp.Txt + "&lat=" + DeliveryAddressPopUp.Lat1 + "&lng=" + DeliveryAddressPopUp.Lng1 + "¬es=" + note_Json + "&self_pick=" + pickOrders; string aa = postData; HttpClient httpClient = new HttpClient(); string boundary = "---8d0f01e6b3b5dafaaadaad"; MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary); try { foreach (var cn in _note) { if (cn.noteImg != null) { var fileContent = new ByteArrayContent(cn.noteImg); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "note_image[]", FileName = cn.id + "_orderNote" + ".png", }; multipartContent.Add(fileContent); } else { string fileName = "Icon"; byte[] array = Encoding.ASCII.GetBytes(fileName); var fileContent = new ByteArrayContent(array); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "note_image[]", FileName = cn.id + "_emptyNote" + ".png", }; multipartContent.Add(fileContent); } } } catch { } string aa1 = postData; HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "createOrder?" + postData, multipartContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content != null) { CreateOrderResult objData = new CreateOrderResult(); objData = Newtonsoft.Json.JsonConvert.DeserializeObject <CreateOrderResult>(content); if (objData.status == 1) { //notes clear AddNotePage.notes.Clear(); App.Database.ClearProduc(); App.Database.ClearAddon(); Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await DisplayAlert("", objData.msg_ar, "OK"); } else { await DisplayAlert("", objData.msg_en, "OK"); } App.Current.MainPage = new NavigationPage(new MainPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } } else { Loader.CloseAllPopup(); await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(response.ReasonPhrase.ToString())); await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } } }
public async void Category() { try { if (!CommonLib.checkconnection()) { await Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } var result = await CommonLib.HomePageCategory(CommonLib.ws_MainUrl + "getCategories?"); if (result.status == 1) { homeCategories = result.data.categories; foreach (var cn in result.data.categories) { catId = cn.id; break; } // InitializeComponent(); loadLatLng(); // bool check = true; foreach (var item in result.data.categories) { if (check == true) { // Label idlbl = new Label() { Text = item.id, IsVisible = false }; CachedImage img = new CachedImage() { Source = CommonLib.img_MainUrl + item.logo, HorizontalOptions = LayoutOptions.Center, HeightRequest = 60, WidthRequest = 60, Aspect = Aspect.AspectFit, LoadingPlaceholder = "product_Placeholder.png", Transformations = new List <ITransformation>() { new FFImageLoading.Transformations.CircleTransformation() { BorderSize = 20, BorderHexColor = "#FE1F78" } }, }; Label namelbl = new Label() { Text = item.name, TextColor = Color.FromHex("#FE1F78"), FontSize = 14, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, FontFamily = "CALIBRI", StyleId = "CALIBRI", }; StackLayout _imglayout = new StackLayout() { Orientation = StackOrientation.Vertical, HeightRequest = 120, BackgroundColor = Color.Transparent, // Padding = new Thickness(5, 5, 5, 5), Children = { idlbl, img, namelbl } }; var lblClose_tgr = new TapGestureRecognizer(); lblClose_tgr.Tapped += LblClose_tgr_Tapped; _imglayout.GestureRecognizers.Add(lblClose_tgr); _categoryLyt.Children.Add(_imglayout); // //Button button = new Button() //{ // Text = item.name,FontAttributes=FontAttributes.Bold, // FontFamily = "CALIBRI",FontSize=16, // StyleId = "CALIBRI", // CornerRadius = 30, // TextColor = Color.White, // BackgroundColor = Color.FromHex("#FE1F78"), // WidthRequest = 150 //}; //button.Clicked += Button_Clicked; //_categoryLyt.Children.Add(button); } else { // Label idlbl = new Label() { Text = item.id, IsVisible = false }; CachedImage img = new CachedImage() { Source = CommonLib.img_MainUrl + item.logo, HorizontalOptions = LayoutOptions.Center, HeightRequest = 60, WidthRequest = 60, Aspect = Aspect.AspectFit, LoadingPlaceholder = "product_Placeholder.png", Transformations = new List <ITransformation>() { new FFImageLoading.Transformations.CircleTransformation() { BorderSize = 20, BorderHexColor = "#68696b" } }, }; Label namelbl = new Label() { Text = item.name, TextColor = Color.FromHex("#68696b"), FontSize = 14, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, FontFamily = "CALIBRI", StyleId = "CALIBRI", }; StackLayout _imglayout = new StackLayout() { Orientation = StackOrientation.Vertical, HeightRequest = 120, BackgroundColor = Color.Transparent, // Padding = new Thickness(5, 5, 5, 5), Children = { idlbl, img, namelbl } }; var lblClose_tgr = new TapGestureRecognizer(); lblClose_tgr.Tapped += LblClose_tgr_Tapped; _imglayout.GestureRecognizers.Add(lblClose_tgr); _categoryLyt.Children.Add(_imglayout); // //Button button = new Button() //{ // Text = item.name, // FontFamily = "CALIBRI", // StyleId = "CALIBRI", // CornerRadius = 30, // TextColor = Color.FromHex("#A3989C"), // BackgroundColor = Color.FromHex("#FFEFF5"), // WidthRequest = 150 //}; //button.Clicked += Button_Clicked; //_categoryLyt.Children.Add(button); } check = false; } } } catch (Exception ex) { } }
private async void done_Clicked(object sender, EventArgs e) { var returnMessage = CheckValidations(); if (!string.IsNullOrEmpty(returnMessage)) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(returnMessage)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); string otp = txtFirstNumber.Text.Trim() + txtSecondNumber.Text.Trim() + txtThirdNumber.Text.Trim() + txtFourthNumber.Text.Trim() + txtFifthNumber.Text.Trim(); string postData = "id=" + id + "&otp=" + otp; var result = await CommonLib.RegisterPhone(CommonLib.ws_MainUrl + "otpVerify?" + postData); if (result.status == 1) { OtpPage.phone = result.data.User.phone; OtpPage.countryCode = result.data.User.country_code; Loader.CloseAllPopup(); await Navigation.PushAsync(new UpdatePasswordPage()); // App.Current.MainPage = new NavigationPage(new SignupPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
//public async void loadDefaultAddress() //{ // try // { // if (!CommonLib.checkconnection()) // { // await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); // await Task.Delay(1000); // ShowMessage.CloseAllPopup(); // return; // } // await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); // LoggedInUser objUser = App.Database.GetLoggedInUser(); // string postData = "user_id=" + objUser.userId + "&id=0"; // var result = await CommonLib.GetCustomerAddressData(CommonLib.ws_MainUrl + "getAddressInfo?" + postData); // if (result.status == 1) // { // deffaultAdd= result.data.UsersAddress.id; // defaultAdd.Text = result.data.UsersAddress.full_address; // Loader.CloseAllPopup(); // } // else // { // Loader.CloseAllPopup(); // } // } // catch (Exception ex) // { // Loader.CloseAllPopup(); // } //} private async void Next_Clicked(object sender, EventArgs e) { // emptyCartLbl cart var emptyCartLbl = App.Database.GetAllProduct(); if (emptyCartLbl.Count == 0) { return; } //empty address if (string.IsNullOrEmpty(addressLbl.Text)) { await DisplayAlert("F & C", AppResources.selectDeliveryAddress, "OK"); return; } //string products = ""; //string paymentMethod = "1"; //try //{ // products = "["; // var _products = App.Database.GetAllProduct(); // foreach (var group in _products) // { // products += "{"; // products += '"' + "id" + '"' + ":" + group.productId + ","; // products += '"' + "quantity" + '"' + ":" + group.productQty + ","; // products += '"' + "addon" + '"' + ":" + "["; // var _addons = App.Database.GetAllProductAddon(Convert.ToString(group.ID)); // foreach (var food in _addons) // { // products += "{"; // products += '"' + "id" + '"' + ":" + food.AddonId + ","; // products += '"' + "quantity" + '"' + ":" + food.AddonQty; // products += "},"; // } // // // if (_addons.Count != 0) // products = products.Substring(0, products.Length - 1); // products += "]"; // products += "},"; // } // // // products = products.Substring(0, products.Length - 1); // products += "]"; //} //catch (Exception) //{ //} //var ans = await App.Current.MainPage.DisplayAlert("", AppResources.createOrder, AppResources.yes, AppResources.no); //if (ans) //{ try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); var result = await CommonLib.GetSettingResult(CommonLib.ws_MainUrl + "setting"); if (result.status == 1) { Loader.CloseAllPopup(); CustomerPaymentPage.deliveryPrice = Convert.ToDouble(result.data.Setting.delivery_fee); CustomerPaymentPage.deliveryPriceTemp = Convert.ToDouble(result.data.Setting.delivery_fee); CustomerPaymentPage.dictancePrice = Convert.ToDouble(result.data.Setting.distance_charge); CustomerPaymentPage.radius = Convert.ToInt32(result.data.Setting.delivery_fee_radius); App.Current.MainPage.Navigation.PushAsync(new CustomerPaymentPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } //} }
private async void done_Clicked(object sender, EventArgs e) { var returnMessage = CheckValidations(); if (!string.IsNullOrEmpty(returnMessage)) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(returnMessage)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } if (isLogin == false) { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); string otp = txtFirstNumber.Text.Trim() + txtSecondNumber.Text.Trim() + txtThirdNumber.Text.Trim() + txtFourthNumber.Text.Trim() + txtFifthNumber.Text.Trim(); string postData = "id=" + id + "&otp=" + otp; var result = await CommonLib.RegisterPhone(CommonLib.ws_MainUrl + "otpVerify?" + postData); if (result.status == 1) { OtpPage.phone = result.data.User.phone; OtpPage.countryCode = result.data.User.country_code; Loader.CloseAllPopup(); App.Current.MainPage = new NavigationPage(new SignupPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } else { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); string otp = txtFirstNumber.Text.Trim() + txtSecondNumber.Text.Trim() + txtThirdNumber.Text.Trim() + txtFourthNumber.Text.Trim() + txtFifthNumber.Text.Trim(); string postData = "id=" + id + "&otp=" + otp; var result = await CommonLib.RegisterPhone(CommonLib.ws_MainUrl + "phoneOtpVerify?" + postData); if (result.status == 1) { OtpPage.phone = result.data.User.phone; OtpPage.countryCode = result.data.User.country_code; Loader.CloseAllPopup(); // Save data in sqlite for login check LoggedInUser objUser = new LoggedInUser(); objUser.userId = Convert.ToInt32(result.data.User.id); objUser.fname = result.data.User.first_name; objUser.lname = result.data.User.last_name; objUser.email = result.data.User.email; objUser.image = CommonLib.img_MainUrl + result.data.User.image; objUser.phone = result.data.User.phone; objUser.userType = result.data.User.userType; objUser.country_code = result.data.User.country_code; objUser.is_shop = result.data.User.is_shop; App.Database.SaveLoggedInUser(objUser); //if (result.data.User.is_shop == "0") //{ // App.Current.MainPage = new NavigationPage(new AddShopPage()); //} //else //{ // App.Current.MainPage = new NavigationPage(new HomeMasterPage()); //} App.Current.MainPage = new NavigationPage(new MainPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } }