private async void btnRecoverPassword_Click(object sender, EventArgs e) { string promptValue = Prompt.ShowDialog("Type in the new password for selected user", "Confirm"); if (promptValue != "") { string pwsalt = GenerateSalt(); string pwhash = GenerateHash(pwsalt, promptValue); UserProfileUpsertRequest request = new UserProfileUpsertRequest() { About = loadedProfile.About, Email = loadedProfile.Email, IsUpdateByAdmin = true, PasswordClearText = "abc", PasswordClearTextConfirm = "abc", PwSalt = pwsalt, PwHash = pwhash, RecommendedAlbum1 = loadedProfile.RecommendedAlbum1, RecommendedAlbum2 = loadedProfile.RecommendedAlbum2, RecommendedAlbum3 = loadedProfile.RecommendedAlbum3, RecommendedArtist1 = loadedProfile.RecommendedArtist1, RecommendedArtist2 = loadedProfile.RecommendedArtist2, RecommendedArtist3 = loadedProfile.RecommendedArtist3, RegisteredAt = loadedProfile.RegisteredAt, Username = loadedProfile.Username, UserPhoto = loadedProfile.UserPhoto, UserWallpaper = loadedProfile.UserWallpaper }; await _userService.Update <UserProfile>(loadedProfile.UserId, request); MessageBox.Show("Task successful."); } }
private void SetRecommended(UserProfileUpsertRequest request) { if (_album1.AlbumId != 0) { request.RecommendedAlbum1 = _album1.AlbumId; } else { request.RecommendedAlbum1 = null; } if (_album2.AlbumId != 0) { request.RecommendedAlbum2 = _album2.AlbumId; } else { request.RecommendedAlbum2 = null; } if (_album3.AlbumId != 0) { request.RecommendedAlbum3 = _album3.AlbumId; } else { request.RecommendedAlbum3 = null; } if (_artist1.ArtistId != 0) { request.RecommendedArtist1 = _artist1.ArtistId; } else { request.RecommendedArtist1 = null; } if (_artist2.ArtistId != 0) { request.RecommendedArtist2 = _artist2.ArtistId; } else { request.RecommendedArtist2 = null; } if (_artist3.ArtistId != 0) { request.RecommendedArtist3 = _artist3.ArtistId; } else { request.RecommendedArtist3 = null; } }
private async void btnSuspend_Click(object sender, EventArgs e) { string suspendText = ""; if (txtSuspended.Text == "No") { suspendText = "Are you sure you want to suspend the selected user?"; } else { suspendText = "Are you sure you want to unsuspend the selected user?"; } var confirmResult = MessageBox.Show(suspendText, "Confirm", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { UserProfileUpsertRequest request = new UserProfileUpsertRequest() { About = loadedProfile.About, Email = loadedProfile.Email, IsUpdateByAdmin = true, PasswordClearText = "abc", PasswordClearTextConfirm = "abc", PwHash = loadedProfile.PasswordHash, PwSalt = loadedProfile.PasswordSalt, RecommendedAlbum1 = loadedProfile.RecommendedAlbum1, RecommendedAlbum2 = loadedProfile.RecommendedAlbum2, RecommendedAlbum3 = loadedProfile.RecommendedAlbum3, RecommendedArtist1 = loadedProfile.RecommendedArtist1, RecommendedArtist2 = loadedProfile.RecommendedArtist2, RecommendedArtist3 = loadedProfile.RecommendedArtist3, RegisteredAt = loadedProfile.RegisteredAt, Username = loadedProfile.Username, UserPhoto = loadedProfile.UserPhoto, UserWallpaper = loadedProfile.UserWallpaper }; if (txtSuspended.Text == "No") { request.SuspendedFlag = true; } else { request.SuspendedFlag = false; } await _userService.Update <UserProfile>(loadedProfile.UserId, request); MessageBox.Show("Task successful."); if (txtSuspended.Text == "No") { txtSuspended.Text = "Yes"; btnSuspend.Text = "Unsuspend User"; } else { txtSuspended.Text = "No"; btnSuspend.Text = "Suspend User"; } refreshHandler?.Invoke(this, null); } }
private async Task SubmitRegistration() { if (ValidateEmptyFields() == false) { await Application.Current.MainPage.DisplayAlert("Error", "Please fill out the required fields (Username,Email,Password,Password Confirmation)", "OK"); return; } if (ValidatePasswordMatch() == false) { await Application.Current.MainPage.DisplayAlert("Error", "Passwords do not match", "OK"); return; } var request = new UserProfileUpsertRequest() { Username = _username, About = _about, Email = _email, PasswordClearText = _password, PasswordClearTextConfirm = _passwordConfirm, RegisteredAt = DateTime.Now, SuspendedFlag = false, UserPhoto = ProfilePhoto, UserWallpaper = Wallpaper }; SetRecommended(request); if (EditProfile == true) { request.RegisteredAt = APIService.loggedProfile.RegisteredAt; await _userService.Update <Model.UserProfile>(APIService.loggedProfile.UserId, request); await Application.Current.MainPage.DisplayAlert("Success", "Profile updated! Please relog for the actions to take change", "OK"); } else { var check = await _userService.Get <List <UserProfile> >(new UserProfileSearchRequest() { Username = request.Username, Email = request.Email }); var check2 = await _administratorLoginService.Get <List <AdministratorLogin> >(new AdminSearchRequest() { AdminName = request.Username }); if (check.Count > 0 || check2.Count > 0) { await Application.Current.MainPage.DisplayAlert("Error", "Username already taken!", "OK"); return; } var returnedUser = await _userService.Insert <Model.UserProfile>(request); await GenerateTracklists(returnedUser.UserId); await Application.Current.MainPage.DisplayAlert("Success", "You have successfully registered your account! You will now be redirected to login page.", "OK"); } APIService.loggedProfile = null; APIService.Username = ""; APIService.Password = ""; Application.Current.MainPage = new LoginPage(); }