public MainMenuTab() { db = new RhodeITDB(); dets = db.GetUserDetails(); Title = "Welcome " + dets.User_ID; menuViewModel = new MainMenuTabsViewModel(); ToolbarItem logOut = new ToolbarItem { Text = "Logout", Order = ToolbarItemOrder.Primary, Priority = 1 }; ToolbarItems.Add(new ToolbarItem("Logout", null, new Action(() => LogOut()), ToolbarItemOrder.Secondary, CheckPlatform())); Content = menuViewModel.main; }
public void Purchase_Ride_Credits() { RhodeITService rhodeITServices = new RhodeITService(); RhodeITDB db = new RhodeITDB(); IUserDialogs dialog = UserDialogs.Instance; dialog.ShowLoading("Purchasing Ride Credits..."); try { bool result = int.TryParse(amount.Text, out int rideCredit); if (!result) { throw new InvalidNumberException("Invalid"); } try { if (rideCredit <= 0) { throw new InvalidNumberException(""); } else { Details = db.GetUserDetails(); rhodeITServices.UpdateCreditRequestAsync(Details.Ethereum_Address, rideCredit).ConfigureAwait(false); Details.RideCredits += rideCredit; RhodesDataBase.ChargeUserRideCreditBalanceToAccount(Details).ConfigureAwait(false); db.UpdateLoginDetails(Details); dialog.HideLoading(); dialog.Alert(string.Format("Succesfully recharged ride credits with {0}", rideCredit), "Success", "OK"); } } catch (Exception e) { dialog.HideLoading(); PopupLayout.Dismiss(); Console.WriteLine("Error whilst purcasing credits: " + e.Message); dialog.Alert("Something went wrong whilst purchasing credit", "Insufficient Funds", "OK"); } } catch (InvalidNumberException e) { dialog.HideLoading(); PopupLayout.Dismiss(); Console.WriteLine("Error whilst purcasing credits: " + e.Message); dialog.Alert("Please ensure you entered a valid number e.g. 12", "Invalid Number", "OK"); } }
public App() { Current.Resources.MergedDictionaries.Clear(); Current.Resources.MergedDictionaries.Add(new LightTheme()); XF.Material.Forms.Material.Init(this); Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Variables.SyncFusionLicense); RhodeITDB db = new RhodeITDB(); LoginDetails dets = db.GetUserDetails(); if (!string.IsNullOrEmpty(dets.User_ID)) { Current.MainPage = new NavigationPage(new MainMenuTab()); } else { Current.MainPage = new LoginPage(); } }