private async Task ForgotPassword() { UserModel um = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { um = WebService.ForgotPassword(txtEmail.Text); }).ContinueWith(async t => { if (um.result == "success") { StaticMethods.ShowToast(um.responseMessage); await Navigation.PushAsync(new LoginPage()); } else { StaticMethods.ShowToast(um.responseMessage); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task ChangePassword() { UserModel um = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { um = WebService.ChangePassword(txtOldPassword.Text, txtNewPassword.Text); }).ContinueWith(async t => { if (um.result == "success") { StaticMethods.ShowToast(um.responseMessage); App.Current.MainPage = new NavigationPage(new MainPage()); } else { StaticMethods.ShowToast(um.responseMessage); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProducts() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _listProduct = WebService.GetAllProductList(); long h = 0; }).ContinueWith(async t => { try { TransformProducts(); _items = new ProductItemsList(_listProduct); //flowlistview1.FlowItemsSource = _items.Items; //_items.Items[0].isEnableListview = true; } catch (Exception ex) { } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task DeleteProduct(string product_id) { string ret = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew(async() => { ret = WebService.DeleteProductByProductId(product_id); }).ContinueWith ((arg) => { Device.BeginInvokeOnMainThread(async() => { if (!string.IsNullOrEmpty(ret)) { StaticMethods.ShowToast("Product has been deleted successfully"); GetProfileData(filterType).Wait(); } else { StaticMethods.ShowToast("Failed to delete product!, Please try again later."); } }); }); StaticMethods.DismissLoader(); }
private async Task Login() { UserModel um = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { um = new UserModel(); um.name = txtUsername.Text; um.password = txtPass.Text; model = WebService.Login(um); }).ContinueWith(async t => { if (model != null) { StaticDataModel.userId = Convert.ToInt32(model.user_id); StaticMethods.SaveLocalData(model); StaticMethods.ShowToast("Login successfully"); StaticDataModel.IsAnonymousLogin = false; App.Current.MainPage = new NavigationPage(new MainPage()); } else { //StaticMethods.ShowToast(um.responseMessage); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task UpdateProfile(ProfileModel.Datum model) { string ret = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { ret = WebService.UpdateProfile(model); }).ContinueWith(async t => { if (ret == "success") { StaticMethods.ShowToast("Profile Updated successfully!"); Navigation.PopModalAsync(); } else { StaticMethods.ShowToast("Failed to update profile!"); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task CheckForSavedUser(string userid) { SavedUserModel saveduserModel = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { saveduserModel = WebService.CheckSavedUser(userid); }).ContinueWith(async t => { if (saveduserModel != null) { if (saveduserModel.data[0].user_is_favorite) { isFavourite = true; imgHeart.Source = "h.png"; } else { isFavourite = false; imgHeart.Source = "h_unlike"; } } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task AddRemoveSaveUser(string userid, string method, string Responsemessage) { string ret = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { ret = WebService.SaveUnsaveUser(userid, method); }).ContinueWith(async t => { if (ret == "success") { StaticMethods.ShowToast(Responsemessage); if (method == "save_users") { isFavourite = true; imgHeart.Source = "h.png"; } else { isFavourite = false; imgHeart.Source = "h_unlike.png"; } } else { StaticMethods.ShowToast("Unable to make changes, Please try again after some time."); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProducts() { StaticMethods.ShowLoader(); _listProduct = WebService.FilterProducts(_typeOfBikes, _condition, _buy_rent, _min_price, _max_price, _max_distance, _gender, _frameSize, _lat, _long ); Device.BeginInvokeOnMainThread(async() => { StaticMethods.DismissLoader(); if (_listProduct != null) { if (_listProduct.Count > 0) { await Navigation.PushAsync(new HomePage(_listProduct)); } else { StaticMethods.ShowToast("No products found!"); } } else { StaticMethods.ShowToast("No products found!"); } }); }
private async Task SavePaypalId() { string ret = string.Empty; try { StaticMethods.ShowLoader(); Task.Factory.StartNew(() => { ret = WebService.SavePaypalId(txtPaypalId.Text); }).ContinueWith((arg) => { Device.BeginInvokeOnMainThread(() => { if (ret.Equals("success")) { StaticMethods.ShowToast("User paypal id saved successfully!"); Navigation.PopModalAsync(); } }); }); } catch (Exception ex) { } finally { StaticMethods.DismissLoader(); } }
private async Task GetProducts() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { //_listProduct = WebService.FilterProducts(_typeOfBikes,_condition,_buy_rent, // Convert.ToInt32(lblStartPriceRange), // Convert.ToInt32(lblEndPriceRange), // Convert.ToInt32(lblEndDistanceRange), // StaticDataModel.Lattitude, // StaticDataModel.Longitude); var list = new List <string> { _model.data[0].type_of_bike }; _listProduct = WebService.FilterProducts(list, null, null, 0, 0, 0, null, null, StaticDataModel.Lattitude, StaticDataModel.Longitude); }).ContinueWith(async t => { Device.BeginInvokeOnMainThread(async() => { if (_listProduct != null) { if (_listProduct.Count > 0) { await Navigation.PushModalAsync(new HomePage(_listProduct)); } else { StaticMethods.ShowToast("No products found!"); } } else { StaticMethods.ShowToast("No products found!"); } }); StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProfile() { StaticMethods.ShowLoader(); Task.Factory.StartNew( () => { _profileModel = WebService.GetProfile(StaticDataModel.userId); }).ContinueWith(async t => { if (_profileModel != null) { Device.BeginInvokeOnMainThread(async() => { lblUserName.Text = _profileModel.data[0].name; lblEmail.Text = _profileModel.data[0].website_url; lblReviews.Text = _profileModel.data[0].total_reviews + " Reviews"; lblMyReviews.Text = _profileModel.data[0].get_review + " Reviews"; lblMail.Text = _profileModel.data[0].email; lblContactNo.Text = _profileModel.data[0].contact_number; lblSavedUser.Text = _profileModel.data[0].saved_users + " Saved Users"; if (!string.IsNullOrEmpty(_profileModel.data[0].profile_pic)) { imgProfile.Source = Constants.ProfilePicUrl + _profileModel.data[0].profile_pic; } if (!string.IsNullOrEmpty(_profileModel.data[0].ratings)) { var val = Math.Round(Convert.ToDouble(_profileModel.data[0].ratings), 3); lblRating.Text = val.ToString(); } var model = StaticMethods.GetLocalSavedData(); if (model != null) { if (model.is_retailer == "1") { imgRibbon.IsVisible = true; } } }); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task SignUp(User user) { UserModel um = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { um = new UserModel(); um.is_social_signup = 1; um.email = user.Email; if (user.Name != null) { um.name = user.Name; } else { um.name = user.First_Name + "" + user.Last_Name; } um.password = "******"; model = WebService.SignUp(um); }).ContinueWith(async t => { if (model != null) { StaticDataModel.userId = Convert.ToInt32(model.user_id); StaticMethods.SaveLocalData(model); StaticMethods.ShowToast("Login successfully"); StaticDataModel.IsAnonymousLogin = false; App.Current.MainPage = new NavigationPage(new MainPage()); } else { StaticMethods.ShowToast("User already exists."); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetReviews() { StaticMethods.ShowLoader(); Task.Factory.StartNew( () => { model = WebService.GetMyReviews(); }).ContinueWith(async t => { if (!ReferenceEquals(model.review_data, null)) { Device.BeginInvokeOnMainThread(async() => { for (int i = 0; i < model.review_data.Count; i++) { if (!string.IsNullOrEmpty(model.review_data[i].profile_pic)) { model.review_data[i].profile_pic = Constants.ProfilePicUrl + model.review_data[i].profile_pic; } else { model.review_data[i].profile_pic = "dummyprofile.png"; } SetRating(Convert.ToInt32(model.review_data[i].rating), i); } flowlistview.FlowItemsSource = model.review_data; }); } else { StaticMethods.ShowToast("No Reviews!"); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetQuestionAnswers() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { questionAnswerModel = WebService.GetWizardQuestionAnswers(); }).ContinueWith(async t => { Device.BeginInvokeOnMainThread(async() => { LoadQuestion(questionNumber); questionNumber++; }); StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task SearchProducts(string searchText) { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _listProduct = WebService.SearchProduct(searchText); long h = 0; }).ContinueWith(async t => { try { if (!ReferenceEquals(_listProduct, null)) { if (_listProduct.Count > 0) { TransformProducts(); _items = new ProductItemsList(_listProduct); } else { DisplayAlert("Alert!", "No bike found!", "Ok"); } } else { DisplayAlert("Alert!", "No bike found!", "Ok"); } } catch (Exception ex) { } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProfile() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _profileModel = WebService.GetProfile(StaticDataModel.userId); }).ContinueWith(async t => { try { if (_profileModel != null) { Device.BeginInvokeOnMainThread(async() => { txtName.Text = _profileModel.data[0].name; txtEmail.Text = _profileModel.data[0].email; txtMobile.Text = _profileModel.data[0].contact_number; txtWebUrl.Text = _profileModel.data[0].website_url; imgProfile.Source = Constants.ProfilePicUrl + _profileModel.data[0].profile_pic; if (!string.IsNullOrEmpty(_profileModel.data[0].ratings)) { var val = Math.Round(Convert.ToDouble(_profileModel.data[0].ratings), 3); //lblRating.Text = val.ToString(); } }); } } catch (Exception ex) { } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetRentSellProducts() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _categoryModel = WebService.GetCategoriesProductbyUserId(_userId); }).ContinueWith(async t => { if (_categoryModel.data.sell != null) { Device.BeginInvokeOnMainThread(async() => { }); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetWizardResult() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { resultModel = WebService.GetWizardResult(answerArray); }).ContinueWith(async t => { Device.BeginInvokeOnMainThread(async() => { if (resultModel != null) { Navigation.PushModalAsync(new BikeWizardFinishPage(resultModel)); } }); StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetAllSavedUsers() { SavedUserModel model = null; StaticMethods.ShowLoader(); Task.Factory.StartNew( () => { model = WebService.GetSavedUser(); }).ContinueWith(async t => { if (model != null) { Device.BeginInvokeOnMainThread(async() => { for (int i = 0; i < model.data.Count; i++) { if (!string.IsNullOrEmpty(model.data[i].profile_pic)) { model.data[i].profile_pic = Constants.ProfilePicUrl + model.data[i].profile_pic; } else { model.data[i].profile_pic = "dummyprofile.png"; } } flowlistview.FlowItemsSource = model.data; }); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task AddComment() { string ret = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { ret = WebService.AddComment(_rating, txtReview.Text); }).ContinueWith(async t => { if (ret == "success") { StaticMethods.ShowToast("Your reviews has been submitted successfully!"); App.Current.MainPage = new NavigationPage(new MainPage()); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProfile() { StaticMethods.ShowLoader(); Task.Factory.StartNew( () => { _profileModel = WebService.GetProfile(_userId); }).ContinueWith(async t => { try { if (_profileModel != null) { Device.BeginInvokeOnMainThread(async() => { lblUserName.Text = _profileModel.data[0].name; lblEmail.Text = _profileModel.data[0].website_url; lblReviews.Text = _profileModel.data[0].total_reviews + " Reviews"; if (!string.IsNullOrEmpty(_profileModel.data[0].profile_pic)) { imgProfile.Source = Constants.ProfilePicUrl + _profileModel.data[0].profile_pic; } else { imgProfile.Source = "dummyprofile.png"; } if (!string.IsNullOrEmpty(_profileModel.data[0].ratings)) { var val = Math.Round(Convert.ToDouble(_profileModel.data[0].ratings), 3); lblRating.Text = val.ToString(); } var model = StaticMethods.GetLocalSavedData(); if (model != null) { if (model.is_retailer == "1") { imgRibbon.IsVisible = true; } } GetProfileData("rent").Wait(); }); } } catch (Exception ex) { } finally { Device.BeginInvokeOnMainThread(() => { GetProfileData("sell").Wait(); }); } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProductsDetails() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _productDetailsModel = WebService.GetProductDetailsbyId(Convert.ToInt32(_productModel.product_id)); }).ContinueWith(async t => { try { if (_productDetailsModel != null) { Device.BeginInvokeOnMainThread(async() => { var imageList = new List <Model>(); var data = _productDetailsModel.product_image; if (!string.IsNullOrEmpty(_productDetailsModel.product_image)) { var imageArray = data.Split(','); for (int i = 0; i < imageArray.Length; i++) { imageList.Add(new Model { image = Constants.ImageUrl + imageArray[i] }); } } Carousel.ItemsSource = imageList; //imgProduct.Source = Constants.ImageUrl + _productDetailsModel.product_image; ; lblUserName.Text = _productDetailsModel.name; lblProductName.Text = _productDetailsModel.product_name; lblSize.Text = _productDetailsModel.framesize; lblGender.Text = _productDetailsModel.gender; lblTypeofBike.Text = _productDetailsModel.type_of_bike; lblCondition.Text = _productDetailsModel.condition; lblPrice.Text = "€" + _productDetailsModel.price; lblProductDesc.Text = _productDetailsModel.product_description; if (!string.IsNullOrEmpty(_productDetailsModel.lat)) { AddBarMarkerOnMap(Convert.ToDouble(_productDetailsModel.lat), Convert.ToDouble(_productDetailsModel.@long)); } else { AddBarMarkerOnMap(25.023176, 39.189978); } if (_productDetailsModel.user_id != StaticDataModel.userId.ToString()) { imgHeart.IsVisible = true; CheckForSavedUser(_productDetailsModel.user_id); } else { imgHeart.IsVisible = false; } }); } } catch (Exception ex) { } finally { StaticMethods.DismissLoader(); } }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task <bool> AddProduct_Rent() { string base64 = string.Empty; ProductModel um = null; string ret = string.Empty; StaticMethods.ShowLoader(); um = new ProductModel(); um.user_id = StaticDataModel.userId; um.gender = lblGender_rent.Text; um.imageByteArray = imageBytes; um.size = lblSize_rent.Text; um.product_name = txtWhatYouAreSelling_rent.Text; um.product_description = txtDescribe_rent.Text; um.type_of_bike = lblTypeofbike_rent.Text; um.address = lblAddress_rent.Text; if (profileData != null) { var bytearray = StaticMethods.StreamToByte(profileData.GetStream()); base64 = Convert.ToBase64String(bytearray); um.product_image = bytearray; var extsn = Path.GetExtension(profileData.Path); var str = extsn.Split('.'); extsn = str[1]; um.extension = extsn; } um.type = 1; um.currency = lblInr_rent.Text; um.price = txtPrice_rent.Text; um.condition = lblCondtition_rent.Text; if (switchrentValue) { um.is_facebook_sharable = 1; } else { um.is_facebook_sharable = 0; } //ret = WebService.AddProduct(um); string addProductResult = await WebService.AddProductUsingMultipart(um); Device.BeginInvokeOnMainThread(() => { StaticMethods.DismissLoader(); }); if (addProductResult == "SUCCESS") { Device.BeginInvokeOnMainThread(() => { ((Application.Current.MainPage as MasterDetailPage).Detail as NavigationPage).PopAsync(true); }); return(true); } else { } return(false); }
private async Task <bool> AddProduct_Sell() { string base64 = string.Empty; string ret = string.Empty; ProductModel um = new ProductModel(); StaticMethods.ShowLoader(); um.user_id = StaticDataModel.userId; um.gender = lblGender_sell.Text; um.size = lblSize_sell.Text; um.imageByteArray = imageBytes; um.product_name = txtWhatYouAreSelling_sell.Text; um.product_description = txtDescribe_sell.Text; um.type_of_bike = lblTypeofbike_sekk.Text; um.address = lblAddress_sell.Text; if (profileData != null) { var bytearray = StaticMethods.StreamToByte(profileData.GetStream()); base64 = Convert.ToBase64String(bytearray); um.product_image = bytearray; var extsn = Path.GetExtension(profileData.Path); var str = extsn.Split('.'); extsn = str[1]; um.extension = extsn; } um.type = 0; um.currency = lblInr_sell.Text; um.price = txtPrice_sell.Text; um.condition = lblCondition_sell.Text; if (switchsellValue) { um.is_facebook_sharable = 1; } else { um.is_facebook_sharable = 0; } //ret = WebService.AddProduct(um); string addProductResult = await WebService.AddProductUsingMultipart(um); Device.BeginInvokeOnMainThread(() => { StaticMethods.DismissLoader(); }); if (addProductResult == "SUCCESS") { Device.BeginInvokeOnMainThread(() => { ((Application.Current.MainPage as MasterDetailPage).Detail as NavigationPage).PopAsync(true); }); return(true); } else { } return(false); /*Task.Factory.StartNew( * // tasks allow you to use the lambda syntax to pass wor * () => * { * * um.user_id = StaticDataModel.userId; * um.gender = lblGender_sell.Text; * um.size = lblSize_sell.Text; * um.imageByteArray = imageBytes; * um.product_name = txtWhatYouAreSelling_sell.Text; * um.product_description = txtDescribe_sell.Text; * um.type_of_bike = lblTypeofbike_sekk.Text; * um.address = lblAddress_sell.Text; * if (profileData != null) * { * var bytearray = StaticMethods.StreamToByte(profileData.GetStream()); * base64 = Convert.ToBase64String(bytearray); * um.product_image = bytearray; * var extsn = Path.GetExtension(profileData.Path); * var str = extsn.Split('.'); * extsn = str[1]; * um.extension = extsn; * } * um.type = 0; * um.currency = lblInr_sell.Text; * * um.price = txtPrice_sell.Text; * um.condition = lblCondition_sell.Text; * if (switchsellValue) * um.is_facebook_sharable = 1; * else * um.is_facebook_sharable = 0; * * * //ret = WebService.AddProduct(um); * WebService.AddProductUsingMultipart(um); * * * }).ContinueWith(async * t => * { * //if (ret == "success") * //{ * // StaticMethods.ShowToast("Product added successfully"); * // await Navigation.PushAsync(new HomePage()); * //} * //else * //{ * // StaticMethods.ShowToast("Failed to add product, Please try after some time."); * //} * * //StaticMethods.DismissLoader(); * * }, TaskScheduler.FromCurrentSynchronizationContext() * );*/ }
private async Task GetProductComments() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _listComments = WebService.GetCommentsList(Convert.ToInt32(_product.product_id)); }).ContinueWith(async t => { try { if (_listComments.comments != null) { if (_listComments.comments != null) { lblProductTitle.Text = _listComments.comments[0].product_name; } items = new CommentItemList(_listComments); for (int i = 0; i < items.Items.Count; i++) { if (items.Items[i].user_id == StaticDataModel.userId.ToString()) { _isProductAdmin = false; } else { _isProductAdmin = true; } items.Items[i].isProductAdminn = _isProductAdmin; var height = items.Items[i].comment_reply.Count * 60; if (items.Items[i].comment_reply.Count > 0) { items.Items[i].isVisibleListView = true; items.Items[i].ListViewHeight = height; for (int j = 0; j < items.Items[i].comment_reply.Count; j++) { items.Items[i].comment_reply[j].profile_pic = Constants.ProfilePicUrl + items.Items[i].comment_reply[j].profile_pic; } } else { items.Items[i].isVisibleListView = false; } items.Items[i].product_image = Constants.ImageUrl + items.Items[i].product_image; } flowlistview.FlowItemsSource = items.Items; if (items.Items.Count > 0) { var lastItem = flowlistview.FlowItemsSource.OfType <object>().Last(); flowlistview.ScrollTo(lastItem, ScrollToPosition.End, false); } } } catch (Exception ex) { } finally { StaticMethods.DismissLoader(); } }, TaskScheduler.FromCurrentSynchronizationContext() ); }
async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e) { StaticMethods.ShowLoader(); var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= OnAuthCompleted; authenticator.Error -= OnAuthError; } try { if (e.IsAuthenticated) { // If the user is authenticated, request their basic user data from Google var UserInfoUrlFacebook = "https://graph.facebook.com/me?fields=email,first_name,last_name"; var UserInfoUrl = "https://www.googleapis.com/oauth2/v2/userinfo"; var GetUserDataUrl = string.Empty; if (flag) { GetUserDataUrl = UserInfoUrlFacebook; } else { GetUserDataUrl = UserInfoUrl; } var request = new OAuth2Request("GET", new Uri(GetUserDataUrl), null, e.Account); var response = await request.GetResponseAsync(); if (response != null) { // Deserialize the data and store it in the account store // The users email address will be used to identify data in SimpleDB string userJson = await response.GetResponseTextAsync(); if (userJson != "Not Found") { App.User = JsonConvert.DeserializeObject <User>(userJson); } } if (account != null) { store.Delete(account, Constants.AppName); } store.Save(account = e.Account, Constants.AppName); if (App.User.Email != null) { SignUp(App.User).Wait(); } //App.Current.MainPage = new NavigationPage(new MainPage()); } } catch (Exception ex) { } finally { StaticMethods.DismissLoader(); } //Navigation.InsertPageBefore(new HomePage(), this); //await Navigation.PopToRootAsync(); }
private async Task GetBuyingProfileData(string filterType) { string imgData = string.Empty; StaticMethods.ShowLoader(); Task.Factory.StartNew( () => { _profileDataModel = WebService.GetBuyingProductByUserId(); }).ContinueWith(async t => { if (_profileDataModel != null) { Device.BeginInvokeOnMainThread(async() => { if (filterType == "rent") { var _listProduct = _profileDataModel.rent; for (int i = 0; i < _listProduct.Count; i++) { if (!string.IsNullOrEmpty(_listProduct[i].product_image)) { imgData = _listProduct[i].product_image; } _listProduct[i].width = itemWidth - 15; _listProduct[i].imageHeight = itemWidth - 50; var array = imgData.Split(','); if (array != null) { _listProduct[i].product_image = Constants.ImageUrl + array[0]; } _listProduct[i].price = "€ " + _listProduct[i].price; } flowlistviewBuying.FlowItemsSource = _listProduct; lblBuyingItemsCount.Text = _listProduct.Count + " ITEMS"; } else if (filterType == "sold") { var _listProduct = _profileDataModel.sold; for (int i = 0; i < _listProduct.Count; i++) { if (!string.IsNullOrEmpty(_listProduct[i].product_image)) { imgData = _listProduct[i].product_image; } _listProduct[i].width = itemWidth - 15; _listProduct[i].imageHeight = itemWidth - 50; var array = imgData.Split(','); if (array != null) { _listProduct[i].product_image = Constants.ImageUrl + array[0]; } _listProduct[i].price = "€ " + _listProduct[i].price; } flowlistviewBuying.FlowItemsSource = _listProduct; lblBuyingItemsCount.Text = _listProduct.Count + " ITEMS"; } }); StaticMethods.DismissLoader(); } }, TaskScheduler.FromCurrentSynchronizationContext() ); }
private async Task GetProducts() { StaticMethods.ShowLoader(); Task.Factory.StartNew( // tasks allow you to use the lambda syntax to pass wor () => { _listProduct = WebService.GetAllProductList(); }).ContinueWith(async t => { try { string imgData = string.Empty; if (_listProduct != null) { for (int i = 0; i < _listProduct.Count; i++) { _listProduct[i].columnWidth = itemWidth; for (int j = 0; j < _listProduct[i].list.Count; j++) { if (_listProduct[i].list.Count <= 2) { _listProduct[i].listviewHeight = itemWidth - 10; } else if (_listProduct[i].list.Count == 4) { _listProduct[i].listviewHeight = (itemWidth * 2) - 20; } else { _listProduct[i].listviewHeight = (itemWidth * 3) - 30; } if (_listProduct[i].list[j].listing_type == "product") { if (_listProduct[i].list[j].add_to_top == "1") { _listProduct[i].list[j].isTopEnable = true; _listProduct[i].list[j].borderColor = "Red"; } else { _listProduct[i].list[j].isTopEnable = false; _listProduct[i].list[j].borderColor = "Silver"; } if (!string.IsNullOrEmpty(_listProduct[i].list[j].product_image)) { imgData = _listProduct[i].list[j].product_image; } _listProduct[i].list[j].width = itemWidth - 15; _listProduct[i].list[j].imageHeight = itemWidth - 50; var array = imgData.Split(','); if (array != null) { _listProduct[i].list[j].product_image = Constants.ImageUrl + array[0]; } } else { _listProduct[i].list[j].product_image = _listProduct[i].list[j].advertisement_img; _listProduct[i].list[j].imageHeight = itemWidth - 20; _listProduct[i].list[j].width = itemWidth - 15; _listProduct[i].list[j].borderColor = "Silver"; } } } _items = new ProductItemsList(_listProduct); flowlistviewViewCellGrid.ItemsSource = _items.Items; } } catch (Exception ex) { } StaticMethods.DismissLoader(); }, TaskScheduler.FromCurrentSynchronizationContext() ); }