private void loginButton_Click(object sender, EventArgs e) { if (inputEmpty()) { return; } var email = getEmailInput(); var pass = getPassInput(); User user; switch (GetUserStatus(email, pass)) { case UserStatus.NotFound: MessageBox.Show("No user found with the provided email/password combination!"); break; case UserStatus.NotApproved: MessageBox.Show("Your registration request has not yet been approved by the administrators!"); break; case UserStatus.ApprovedUser: user = GetUser(email, pass); var dashboardForm = new UserDashboardForm(_db, user); this.Hide(); dashboardForm.Show(); break; case UserStatus.FirstLogin: user = GetUser(email, pass); var firstLoginForm = new FirstLoginForm(_db, user); this.Hide(); firstLoginForm.Show(); break; case UserStatus.Admin: var adminForm = new AdminForm(_db); this.Hide(); adminForm.Show(); break; default: break; } }
private void button1_Click(object sender, EventArgs e) { var age = getAge(); var gender = getGender(); var selectedGenres = getFavoriteGenres(); if (invalidInput(age, gender, selectedGenres)) { MessageBox.Show("Please fill all required fields!"); return; } _user.Age = age; _user.Gender = gender; _user.FavoriteGenres = genres.Where(g => selectedGenres.Contains(g.Name)).ToList(); _user.UserStatus = UserStatus.ApprovedUser; _db.SaveChanges(); var dashboardForm = new UserDashboardForm(_db, _user); this.Hide(); dashboardForm.Show(); }
private void movieListView_ButtonClick(object sender, BrightIdeasSoftware.CellClickEventArgs e) { var selectedMovie = (Movie)e.Item.RowObject; if (e.Column == descriptionColumn) { MessageBox.Show(selectedMovie.Description); return; } if (e.Column == likeColumn) { var umovie = _user.UserMovies.Where(um => um.Movie.Id == selectedMovie.Id).FirstOrDefault(); if (umovie != null) { if (umovie.MovieStatus == MovieStatus.Owned) { umovie.MovieStatus = MovieStatus.Liked; } else { umovie.MovieStatus = MovieStatus.Owned; } _db.SaveChanges(); } } if (e.Column == dislikeColumn) { var umovie = _user.UserMovies.Where(um => um.Movie.Id == selectedMovie.Id).FirstOrDefault(); if (umovie != null) { if (umovie.MovieStatus == MovieStatus.Owned) { umovie.MovieStatus = MovieStatus.Disliked; } else { umovie.MovieStatus = MovieStatus.Owned; } _db.SaveChanges(); } } if (e.Column == purchaseColumn) { var creditCardNo = UserDashboardForm.ShowDialog("Insert credit card No.", "Purchase " + selectedMovie.Title); if (String.IsNullOrEmpty(creditCardNo) || creditCardNo.Length != 19) { MessageBox.Show("Invalid card number!"); } else { var umovie = new UserMovie() { Movie = selectedMovie, User = _user, MovieStatus = MovieStatus.Owned }; _user.UserMovies.Add(umovie); _db.SaveChanges(); } } refreshList(); }