/// <summary>
        /// Creates registrations for the courses that were selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            List <string> selectedCourseCodes = new List <string>();

            foreach (GridViewRow row in GVCourses.Rows)
            {
                CheckBox chkSelection = (CheckBox)row.FindControl("ChkSelectCourse");
                if (chkSelection.Checked)
                {
                    selectedCourseCodes.Add(row.Cells[1].Text);
                }
            }

            CourseDAO              courseDAO              = new CourseDAO(connectionString);
            UserTableDAO           userTableDAO           = new UserTableDAO(connectionString);
            RegistrationRequestDAO registrationRequestDAO = new RegistrationRequestDAO(connectionString);

            foreach (string code in selectedCourseCodes)
            {
                Course course       = courseDAO.SearchByCourseCode(code);
                User   loggedInUser = userTableDAO.SearchByEmail(Context.User.Identity.Name);
                registrationRequestDAO.AddRegistrationRequest(
                    new RegistrationRequest(loggedInUser, course, Status.NEW));
            }

            // Redirect to dashboard so they can see the request went through
            Response.Redirect("./UserDashboard.aspx");
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a user based on the user's input. Validation handled by jQuery.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnCreate_Click(object sender, EventArgs e)
        {
            // Get all inputs
            string         name  = TxtName.Text;
            string         email = TxtEmail.Text;
            string         phone = TxtPhone.Text;
            EducationLevel level = (EducationLevel)Enum.Parse(typeof(EducationLevel),
                                                              DDEducation.SelectedItem.ToString());
            string birthday = TxtBirthday.Text;
            string password = TxtPassword.Text;

            User user = null;

            if (string.IsNullOrEmpty(phone))
            {
                user = new User(name, email, level, birthday, password);
            }
            else
            {
                user = new User(name, email, phone, level, birthday, password);
            }

            UserTableDAO userDao = new UserTableDAO(ConfigurationManager.ConnectionStrings["flexiLearn"].ConnectionString);

            userDao.AddUser(user);

            LblSuccess.Text = "Account successfully created. <a href='login.aspx'>You may login here</a>.<br><br>";
        }
Esempio n. 3
0
        public static ResultModel IsCreatedUserInDataBase(UserModel newUser)
        {
            var userTableDao = new UserTableDAO();

            var userInDb = userTableDao.ReturnUser(newUser.username);

            var isCreatedUserInDataBase = newUser.IsEqual(userInDb);

            return(new ResultModel()
            {
                result = isCreatedUserInDataBase,
                message = isCreatedUserInDataBase ? AssertionsMessages.UserCreatedSucces : AssertionsMessages.UserCreatedFail
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Populates the gridview to show all request data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            RegistrationRequestDAO requestDAO = new RegistrationRequestDAO(
                ConfigurationManager.ConnectionStrings["flexiLearn"].ConnectionString);

            userRequests = requestDAO.GetAllUserRequests(Context.User.Identity.Name);

            UserTableDAO userDAO = new UserTableDAO(
                ConfigurationManager.ConnectionStrings["flexiLearn"].ConnectionString);
            User user = userDAO.SearchByEmail(Context.User.Identity.Name);

            LblName.Text = user.Name;

            if (!IsPostBack)
            {
                GVRegistrationRequests.DataSource = userRequests;
                GVRegistrationRequests.DataBind();
            }
        }
        /// <summary>
        /// Will authenticate users
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            // Get inputs
            string email    = TxtEmail.Text;
            string password = TxtPassword.Text;

            // Authenticate and redirect depending on whether successful or not
            UserTableDAO userDao = new UserTableDAO(
                ConfigurationManager.ConnectionStrings["flexiLearn"].ConnectionString);

            if (userDao.AuthenticateUser(email, password))
            {
                FormsAuthentication.RedirectFromLoginPage(email, false);
            }
            else
            {
                LblFail.Text = "Email or password incorrect";
            }
        }
        public void DeleteCreatedUsers()
        {
            var userTable = new UserTableDAO();

            userTable.ClearUserTable();
        }