Exemplo n.º 1
0
        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();
        }