// TODO: on save - send to firebase and navigate to home public async void SaveClicked(object sender, EventArgs e) { if (cardNo.Text.Length > 0 && mm.Text.Length > 0 && yyyy.Text.Length > 0) { GlobalData.USER_CARD = new Models.Lannister.Card { CardNumber = cardNo.Text, ExpiryMonth = mm.Text, ExpiryYear = yyyy.Text }; // Save to firebase FirebaseUser user = new FirebaseUser { PhoneNumber = GlobalData.PHONE_NUMBER, UserCard = GlobalData.USER_CARD, UserWallets = GlobalData.USER_WALLETS }; GlobalData.USER_RECORD_STRING = await firesharpClient.Push <FirebaseUser>("users/", user); // Navigate to Home Navigation.PushAsync(new UserHome()); while (Navigation.NavigationStack.Count > 1) { Navigation.RemovePage(Navigation.NavigationStack[0]); } } }
public async void insertRandomDelivery() { Payment p = new Payment(); p.Address = "something 1"; p.Name = "new 1"; p.MerchantName = "KFC"; p.Amount = 360; p.OrderId = "#123"; p.PaymentType = "ONLINE"; p.Status = "PENDING"; p.PhoneNumber = "8217832121"; await fsClient.Push <Payment>("payments", p); //+p.Amount = Convert.ToInt32(Ran) }
private async void SaveBtn(object sender, EventArgs e) { ToolbarItem i = sender as ToolbarItem; i.Clicked -= SaveBtn; var hud = DependencyService.Get <IHUDProvider>(); hud.DisplayProgress("Saving Data"); await Task.Delay(500); if (!string.IsNullOrWhiteSpace(nameEntry.Text) && categoryPicker.SelectedIndex >= 0 && !string.IsNullOrWhiteSpace(addressEntry.Text) && !string.IsNullOrWhiteSpace(landmarkEntry.Text) && ViewModel.Items.Count > 0) { if (CrossConnectivity.Current.IsConnected) { FireSharpClient FsClient = FireSharpClient.Instance; if (IsLocation == false) { GoogleMapsService googleMapsService = GoogleMapsService.Instance; var l = await googleMapsService.GetLocationFromAddress(addressEntry.Text); if (l != null) { CurrentLatitude = l.lat; CurrentLongitude = l.lng; } else { var addressInvalid = "Address is not available on Google Maps"; addressInvalid.ToToast(ToastNotificationType.Error); } } Store s = new Store { Name = nameEntry.Text, Category = AppConstants.CATEGORIES[categoryPicker.SelectedIndex], Address = addressEntry.Text, IsLocation = this.IsLocation, Latitude = this.CurrentLatitude, Longitude = this.CurrentLongitude, Landmark = landmarkEntry.Text }; List <string> tempList = new List <string>(); foreach (var item in ViewModel.Items) { tempList.Add(item.Name); } s.Tags = tempList.ToArray(); var pushKey = await FsClient.Push("stores", s); hud.Dismiss(); await Navigation.PopAsync(); var msg = "Your data has been saved."; msg.ToToast(ToastNotificationType.Error); } else { hud.Dismiss(); var msg = "Make sure you're connected to Internet."; msg.ToToast(ToastNotificationType.Error); } } else { hud.Dismiss(); var msg = "Please Fill All the Fields"; msg.ToToast(ToastNotificationType.Error); } hud.Dismiss(); i.Clicked += SaveBtn; }
private async void OnAddReviewBtnClicked(object sender, EventArgs e) { var s = BindingContext as string; int rating; if (starFive.IsStarred) { rating = 5; } else if (starFour.IsStarred) { rating = 4; } else if (starThree.IsStarred) { rating = 3; } else if (starTwo.IsStarred) { rating = 2; } else { rating = 1; } var r = new Review { Rating = rating, Description = feedbackEntry.Text, Date = DateTime.Now.ToString("MMM dd") }; if (CrossConnectivity.Current.IsConnected) { FireSharpClient FsClient = FireSharpClient.Instance; var hud = DependencyService.Get <IHUDProvider>(); hud.DisplayProgress("Sending Data"); var pushKey = await FsClient.Push("stores/" + s + "/Reviews", r); if (pushKey == null) { var msg = "Server Error :("; msg.ToToast(ToastNotificationType.Error); } else { var msg = "Review Received! Thank You"; msg.ToToast(ToastNotificationType.Success); var x = this.Parent; var y = this.ParentView; var z = this.ParentView.BindingContext; //(BindingContext as StoreDetailViewModel).RefreshData.Execute(this); } hud.Dismiss(); } else { var hud = DependencyService.Get <IHUDProvider>(); hud.DisplayError("Please Connect to Internet."); } }