public ChangePasswordViewModel() { Messenger.Default.Register <String>(this, loginResponse => { _loginResponse = loginResponse; System.Diagnostics.Debug.WriteLine("###### recieved AccountUpdateViewModel ######"); System.Diagnostics.Debug.WriteLine(_loginResponse); JsonTools test = new JsonTools(); _userID = test.JsonGetIdUser(_loginResponse); }); SubmitCommandChangePasswordViewModel = new RelayCommand(() => { Globals test_global = null; test_global = Globals.getInstance(); HTTPRequest connect = new HTTPRequest(); connect.RequestFinished += new HTTPRequest.RequestFinishedEventHandler(this.doChangePassword); connect.HttpPutRequest(test_global.IpAPI + "api/users/" + _userID + "/password", "{ \"current_password\":\"" + this.CurrentPassword + "\",\n\"new_password\":\"" + this.NewPassword + "\" }"); INavigationService navigationService = SimpleIoc.Default.GetInstance <INavigationService>(); navigationService.GoBack(); }); CancelCommandAccountUpdateViewModel = new RelayCommand(() => { NewPassword = ""; CurrentPassword = ""; }); }
public AccountUpdateViewModel() { Messenger.Default.Register <String>(this, loginResponse => { _loginResponse = loginResponse; System.Diagnostics.Debug.WriteLine("###### recieved AccountUpdateViewModel ######"); System.Diagnostics.Debug.WriteLine(_loginResponse); JsonTools test = new JsonTools(); _userID = test.JsonGetIdUser(_loginResponse); byteArray = null; contentType = null; AccountInformationDisplay(); }); AcceptCommandAccountUpdateViewModel = new RelayCommand(() => { Globals test_global = null; test_global = Globals.getInstance(); HTTPRequest connect = new HTTPRequest(); connect.RequestFinished += new HTTPRequest.RequestFinishedEventHandler(this.doEditProfile); connect.HttpPutRequest(test_global.IpAPI + "api/users/" + _user.Id + "/personal_data", "{ \"firstname\":\"" + FirstName + "\",\n\"lastname\":\"" + LastName + "\",\n\"email\":\"" + _user.Email + "\",\n\"message\":\"" + Message + "\" }"); System.Diagnostics.Debug.WriteLine("byteArray => " + byteArray); System.Diagnostics.Debug.WriteLine("contentType => " + contentType); if (contentType != null && byteArray != null) { HTTPRequest connect_sec = new HTTPRequest(); connect_sec.RequestFinished += new HTTPRequest.RequestFinishedEventHandler(this.doEditProfile2); connect_sec.HttpPutRequestUpload(test_global.IpAPI + "api/users/" + _user.Id + "/photo", byteArray, contentType); } INavigationService navigationService = SimpleIoc.Default.GetInstance <INavigationService>(); Messenger.Default.Send(_loginResponse); navigationService.GoBack(); }); CancelCommandAccountUpdateViewModel = new RelayCommand(() => { UserName = _user.UserName; FirstName = _user.FirstName; LastName = _user.LastName; Email = _user.Email; //this.UserImage.ImageSource = new BitmapImage(new Uri(_user.PictureURL, UriKind.Absolute)); PictureURL = new BitmapImage(new Uri(_user.PictureURL, UriKind.Absolute)); Message = _user.Message; INavigationService navigationService = SimpleIoc.Default.GetInstance <INavigationService>(); navigationService.GoBack(); }); ChangePasswordCommandAccountUpdateViewModel = new RelayCommand(() => { System.Diagnostics.Debug.WriteLine("AccountUpdateCommandAccountPage click :)"); INavigationService navigationService = SimpleIoc.Default.GetInstance <INavigationService>(); Messenger.Default.Send(_loginResponse); navigationService.NavigateTo(ViewModelLocator.NavigationChangePasswordView); }); ImageProfileCommandAccountUpdateViewModel = new RelayCommand(async() => { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".gif"); openPicker.FileTypeFilter.Add(".ico"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { System.Diagnostics.Debug.WriteLine("Picked photo: " + file.Name); contentType = file.ContentType; Stream requestStream = await file.OpenStreamForReadAsync(); byteArray = null; using (MemoryStream ms = new MemoryStream()) { await requestStream.CopyToAsync(ms); byteArray = ms.ToArray(); } StorageFile storageFile = file; var stream = await storageFile.OpenAsync(FileAccessMode.Read); var bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(stream); var decodeur = await BitmapDecoder.CreateAsync(stream); PictureURL = bitmapImage; } else { System.Diagnostics.Debug.WriteLine("Operation cancelled."); } }); }