protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                // Validate the user password
                var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>();

                // This doen't count login failures towards account lockout
                // To enable password failures to trigger lockout, change to shouldLockout: true
                var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false);

                switch (result)
                {
                case SignInStatus.Success:
                    Instructor instructor = GrouperMethods.GetInstructor(Email.Text.ToLower().Trim());

                    if (instructor != null)
                    {
                        Session["InstructorID"] = instructor.InstructorID;
                    }
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                    break;

                case SignInStatus.LockedOut:
                    Response.Redirect("/Account/Lockout");
                    break;

                case SignInStatus.RequiresVerification:
                    Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
                                                    Request.QueryString["ReturnUrl"],
                                                    RememberMe.Checked),
                                      true);
                    break;

                case SignInStatus.Failure:
                default:
                    FailureText.Text     = "Invalid login attempt";
                    ErrorMessage.Visible = true;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        protected void BindGridView()
        {
            string userName = Context.User.Identity.GetUserName();

            List <InstructorCourse> courses = new List <InstructorCourse>();

            if (!string.IsNullOrEmpty(userName))
            {
                Instructor instructor = GrouperMethods.GetInstructor(userName);

                if (instructor != null)
                {
                    InstructorNameLabel.Text = instructor.FirstName + " " + instructor.LastName;
                }

                courses = GrouperMethods.GetInstructorCourses(instructor.InstructorID);

                if (courses.Count > 0)
                {
                    CoursesPanel.Visible          = true;
                    NoCoursesPanel.Visible        = false;
                    AddCourseSectionPanel.Visible = false;
                }
                else
                {
                    AddCourseSectionPanel.Visible = false;
                    NoCoursesPanel.Visible        = true;
                    CoursesPanel.Visible          = false;
                }
            }
            //else
            //{
            //    courses = GrouperMethods.GetInstructorCourses();
            //}
            CoursesGridView.DataSource = courses;
            CoursesGridView.DataBind();
        }
Ejemplo n.º 3
0
        protected void SaveCourseLinkButton_Click(object sender, EventArgs e)
        {
            string     userName   = Context.User.Identity.GetUserName();
            Instructor instructor = GrouperMethods.GetInstructor(userName);

            if (instructor != null)
            {
                InstructorCourse course = new InstructorCourse();
                course.InstructorID = instructor.InstructorID;
                course.CourseID     = int.Parse(CoursesDropDownList.SelectedValue);
                course.TermNumber   = int.Parse(TermsDropDownList.SelectedValue);
                course.Year         = int.Parse(YearsDropDownList.SelectedValue);

                switch (course.TermNumber)
                {
                case 1:
                    course.TermName = "Fall " + course.Year.ToString();
                    break;

                case 2:
                    course.TermName = "Winter " + course.Year.ToString();
                    break;

                case 3:
                    course.TermName = "Spring " + course.Year.ToString();
                    break;

                case 4:
                    course.TermName = "Summer " + course.Year.ToString();
                    break;
                }

                int instructorCourseID = GrouperMethods.InsertInstructorCourse(course);

                BindGridView();
            }
        }