private void saveChanges_Click(object sender, EventArgs e) { var mainForm = (SoftCinemaForm)((Button)sender).Parent.Parent.Parent; mainForm.RenderSideBar(); try { string email = this.emailTextBox.Text; string phoneNumber = this.phoneNumberTextBox.Text; string password = this.passwordTextBox.Text; Models.Image profilePic = new Models.Image() { Content = imageBytes }; ImageService.AddImage(profilePic.Content); bool isDeleted = false; UserService.AddOrUpdateUser(user.Username, password, email, phoneNumber, (Role)user.Role, profilePic); user.ProfilePicture = profilePic; UserService.AddImageToUser(user, profilePic); UserService.AddImageToUser(MyAccountForm._currentUser, profilePic); MyAccountForm._currentUser = user; TopPanelForm.ShowGreetings(); } catch (Exception exception) { MessageBox.Show(Constants.ErrorMessages.UserUpdateErrorMesage); } SoftCinemaForm.SetContentHolderForm(new MyAccountForm()); }
private void loginButton_Click(object sender, EventArgs e) { var username = this.usernameTextBox.Text; var password = this.passwordTextBox.Text; try { if (UserService.Validations.isUsernamePasswordMatching(username, password) && !UserService.Validations.IsUserDeleted(username)) { AuthenticationManager.Login(UserService.GetUser(username)); MessageBox.Show(Constants.SuccessMessages.SuccessfulLogin); TopPanelForm.ShowGreetings(); //Refresh main form's sidebar var mainForm = (SoftCinemaForm)((Button)sender).Parent.Parent.Parent; mainForm.RenderSideBar(); //Redirect to home page view SoftCinemaForm.SetContentHolderForm(new HomeForm()); } else { MessageBox.Show(Constants.ErrorMessages.InvalidLogin); } } catch (Exception exception) { MessageBox.Show(Constants.ErrorMessages.InvalidLogin); } }