public async void SaveChange() { if (!CheckValidNewPassword()) { return; } ShowError = false; (UserSettingView.GetInstance().BindingContext as UserSettingViewModel).ChangePassword(NewPassword); await App.Current.MainPage.Navigation.PopAsync(); }
public async void ChangeImage() { try { string[] types = { "image/*" }; FileData fileData = await CrossFilePicker.Current.PickFile(types); if (fileData == null) { return; // user canceled file picking } string path = fileData.FilePath; UserImage = (ImageSource)path; ImagePath = path; isNewImage = true; } catch (Exception ex) { var page = UserSettingView.GetInstance(); await page.DisplayAlert("Error", "Error picking file from divice, try again!", "Ok"); } }
public async void SaveChange() { //TEST INTERNET CONNECTTION var httpClient = new HttpClient(); string x = ""; try { var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test"); x = testInternet; } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK"); return; } string message = CheckInfor(); if (message != "") { var app = GroceryApp.Views.Drawer.AppDrawer.GetInstance(); app.DisplayAlert("Error", message, "OK"); return; } if (ImagePath != "" && isNewImage) { Account account = new Account( "ungdung-grocery-xamarin-by-dk", "378791526477571", "scsyCxQS_C74MbAGdOutpwrzlnU" ); Cloudinary cloudinary = new Cloudinary(account); var uploadParams = new ImageUploadParams() { File = new FileDescription(ImagePath) }; try { using (UserDialogs.Instance.Loading("Saving..")) { var uploadResult = await cloudinary.UploadAsync(uploadParams); string url = uploadResult.SecureUri.ToString(); CurrentUser.ImageURL = url; isNewImage = false; } } catch (Exception ex) { var page = UserSettingView.GetInstance(); await page.DisplayAlert("Error", "Error upload image to server, try again!", "Ok"); } } CurrentUser.UserName = FullName; CurrentUser.PhoneNumber = PhoneNumber; CurrentUser.BirthDate = BirthDate; CurrentUser.Email = Email; CurrentUser.Password = MD5Service.EncodeToMD5(Infor.Password); using (UserDialogs.Instance.Loading("Updating..")) { //update user ở database server await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "user/update", CurrentUser); //update user ở database local DataUpdater.UpdateUser(CurrentUser); } MessageService.Show("Update infor successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataUpdateUser(CurrentUser); PushNotificationService.Push(NotiNumber.UpdateUser, datas, true); }
private AppDrawer() { InitializeComponent(); Shell.SetTabBarIsVisible(this, false); Shell.SetNavBarIsVisible(this, false); //Item CUSTOMER var shoppingTabs = new ShellContent() { Content = TabBarCustomer.GetInstance(), Title = "Shopping", Icon = "drawercart" }; tabShopping.Items.Add(shoppingTabs); flyoutShopping.Items.Add(tabShopping); appShell.Items.Add(flyoutShopping); //Item STORE var storeTabs = new ShellContent() { Content = TabbarStoreManager.GetInstance(), Title = "Your store", Icon = "drawerstore" }; tabStore.Items.Add(storeTabs); flyoutStore.Items.Add(tabStore); appShell.Items.Add(flyoutStore); //Item SETTING var settingTab = new ShellContent() { Content = UserSettingView.GetInstance(), Title = "Setting", Icon = "drawersetting" }; tabSetting.Items.Add(settingTab); flyoutUserSetting.Items.Add(tabSetting); appShell.Items.Add(flyoutUserSetting); //Item LOGOUT var logoutTab = new ShellContent() { Content = new LogoutView(), Title = "Logout", Icon = "flatlogout" }; tabLogout.Items.Add(logoutTab); flyoutLogout.Items.Add(tabLogout); appShell.Items.Add(flyoutLogout); //appShell.CurrentItem.PropertyChanged += CurrentItem_PropertyChanged; flyoutShopping.PropertyChanged += FlyoutShopping_PropertyChanged; flyoutStore.PropertyChanged += FlyoutStore_PropertyChanged; flyoutUserSetting.PropertyChanged += FlyoutUserSetting_PropertyChanged; DataProvider dataProvider = DataProvider.GetInstance(); User user = dataProvider.GetUserByIDUser(Infor.IDUser); this.BindingContext = user; }