Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsLoggedIn)
     {
         UrlUtility.Redirect(WebsitePages.HOME_PAGE);
     }
     else if (!AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor))
     {
         UrlUtility.Redirect(WebsitePages.LoggedIn.HOME_PAGE);
     }
     else
     {
         CurrentRole = Roles.Tutor;
         // if (!IsPostBack)
         // {
         //     if (navLinkHome != null)
         //     {
         //  navLinkHome.HRef = WebsitePages.Tutor.HOME_PAGE;
         //  navLinkCreateSession.HRef = WebsitePages.Tutor.SESSION_MANAGEMENT;
         //   navLinkReports.HRef = WebsitePages.Tutor.REPORTS;
         //   navLinkRequestedSessions.HRef = WebsitePages.Tutor.REQUESTED_SESSIONS;
         // }
         //}
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (IsLoggedIn)
                {
                    if (CurrentUser.UserRoles.Count > 1)
                    {
                        divAdminLink.Visible = AccessManagementValidator.UserHasRole(CurrentUser, Roles.Admin);

                        divTutorLink.Visible = AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor);

                        divStudentLink.Visible = AccessManagementValidator.UserHasRole(CurrentUser, Roles.Student);
                    }
                    else if (CurrentUser.UserRoles.Count == 1)
                    {
                        String webpage = WebsitePages.HOME_PAGE;
                        if (CurrentUser.UserRoles.First().Role.Name.Equals(Roles.Admin.ToString()))
                        {
                            webpage = WebsitePages.Admin.HOME_PAGE;
                        }
                        else if (CurrentUser.UserRoles.First().Role.Name.Equals(Roles.Tutor.ToString()))
                        {
                            webpage = WebsitePages.Tutor.HOME_PAGE;
                        }
                        else if (CurrentUser.UserRoles.First().Role.Name.Equals(Roles.Student.ToString()))
                        {
                            webpage = WebsitePages.Student.HOME_PAGE;
                        }
                        UrlUtility.Redirect(webpage);
                    }
                    else
                    {
                        divAdminLink.Visible = false;

                        divTutorLink.Visible = false;

                        divStudentLink.Visible = false;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsLoggedIn)
            {
                UrlUtility.Redirect(WebsitePages.HOME_PAGE);
            }
            else if (!AccessManagementValidator.UserHasRole(CurrentUser, Roles.Admin))
            {
                UrlUtility.Redirect(WebsitePages.LoggedIn.HOME_PAGE);
            }
            else
            {
                //navLinkHome.HRef = WebsitePages.Admin.HOME_PAGE;
                // navLinkManageUsers.HRef = WebsitePages.Admin.USERS_MANAGEMENT;
                // navLinkCourseManagement.HRef = WebsitePages.Admin.COURSE_MANAGEMENT;
                // navLinkCatalogManagement.HRef = WebsitePages.Admin.CATALOG_MANAGEMENT;
                // navLinkCourseRequests.HRef = WebsitePages.Admin.COURSES_REQUESTS;

                CurrentRole = Roles.Admin;
            }
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsLoggedIn)
     {
         UrlUtility.Redirect(WebsitePages.HOME_PAGE);
     }
     else if (!AccessManagementValidator.UserHasRole(CurrentUser, Roles.Student))
     {
         UrlUtility.Redirect(WebsitePages.LoggedIn.HOME_PAGE);
     }
     else
     {
         CurrentRole = Roles.Student;
     }
     //  if (!IsPostBack)
     // {
     //  navLinkHome.HRef = WebsitePages.Student.HOME_PAGE;
     //  navLinkSessionSearchResults.HRef = WebsitePages.Student.SESSION_SEARCH_RESULTS;
     //  navLinkEnrolledSessions.HRef = WebsitePages.Student.SESSION_MANAGEMENT;
     //  }
 }
Ejemplo n.º 5
0
        protected void btnSaveRoles_Click(object sender, EventArgs e)
        {
            if (IsLoggedIn)
            {
                String message                = string.Empty;
                IUserManagementService um     = new UserManagementService();
                Result <OlescUser>     result = um.GetUser(hfUserEmail.Value);
                if (result.isSuccess)
                {
                    if (chkrole.Items[0].Selected && !AccessManagementValidator.UserHasRole(result.resultObject, Roles.Admin))
                    {
                        // selected student box AND he is not a student already
                        Result <object> AssignRole = um.AssignRole(hfUserEmail.Value, (int)Roles.Admin);

                        if (AssignRole.isSuccess)
                        {
                            message += "\nAdmin role added";
                        }

                        else
                        {
                            message += "\nFailed to add Admin role";
                        }
                    }

                    if (!chkrole.Items[0].Selected && AccessManagementValidator.UserHasRole(result.resultObject, Roles.Admin))
                    {
                        // UNselected student box AND he IS a student then remove this role
                        Result <object> DeAssignRole = um.DeAssignRole(hfUserEmail.Value, (int)Roles.Admin);

                        if (DeAssignRole.isSuccess)
                        {
                            message += "\nAdmin role deassigned successfuly";
                        }

                        else
                        {
                            message += "\nFailed to deassign Admin role";
                        }
                    }

                    if (chkrole.Items[1].Selected && !AccessManagementValidator.UserHasRole(result.resultObject, Roles.Student))
                    {
                        // selected student box AND he is not a student already
                        Result <object> AssignRole = um.AssignRole(hfUserEmail.Value, (int)Roles.Student);

                        if (AssignRole.isSuccess)
                        {
                            message += "\nStudent role added";
                        }

                        else
                        {
                            message += "\nFailed to add student role";
                        }
                    }

                    if (!chkrole.Items[1].Selected && AccessManagementValidator.UserHasRole(result.resultObject, Roles.Student))
                    {
                        // UNselected student box AND he IS a student then remove this role
                        Result <object> DeAssignRole = um.DeAssignRole(hfUserEmail.Value, (int)Roles.Student);

                        if (DeAssignRole.isSuccess)
                        {
                            message += "\nStudent role deassigned successfuly";
                        }

                        else
                        {
                            message += "\nFailed to deassign student role";
                        }
                    }

                    if (chkrole.Items[2].Selected && !AccessManagementValidator.UserHasRole(result.resultObject, Roles.Tutor))
                    {
                        //selected tutor box AND he is not a tutor already
                        Result <object> AssignRole = um.AssignRole(hfUserEmail.Value, (int)Roles.Tutor);

                        if (AssignRole.isSuccess)
                        {
                            message += "\nTutor role added";
                        }

                        else
                        {
                            message += "\nFailed to add tutor role";
                        }
                    }

                    if (!chkrole.Items[2].Selected && AccessManagementValidator.UserHasRole(result.resultObject, Roles.Tutor))
                    {
                        // UNselected tutor box AND he IS a Tutor then remove this role
                        Result <object> DeAssignRole = um.DeAssignRole(hfUserEmail.Value, (int)Roles.Tutor);

                        if (DeAssignRole.isSuccess)
                        {
                            message += "\nTutor role deassigned successfuly";
                        }

                        else
                        {
                            message += "\nFailed to deassign Tutor role";
                        }
                    }
                }
                else
                {
                    message = result.message;
                }
                ShowMessage(message);
            }
        }
Ejemplo n.º 6
0
        protected void submit_Click(object sender, EventArgs e)
        {
            if (IsLoggedIn)
            {
                //Validate Selections for student
                if (chkrole.Items[0].Selected)
                {
                    if (string.IsNullOrEmpty(ddlMajors.SelectedValue))
                    {
                        rfvMajor.IsValid = false;
                    }
                    else
                    {
                        rfvMajor.IsValid = true;
                    }

                    if (string.IsNullOrEmpty(ddlCollege.SelectedValue))
                    {
                        rfvCollege.IsValid = false;
                    }
                    else
                    {
                        rfvCollege.IsValid = true;
                    }
                }
                else
                {
                    rfvMajor.IsValid   = true;
                    rfvCollege.IsValid = true;
                }

                if (rfvMajor.IsValid && rfvCollege.IsValid)
                {
                    String message = String.Empty;
                    CurrentUser.UserProfile.FirstName = txtFirstName.Text;
                    CurrentUser.UserProfile.LastName  = txtLastName.Text;
                    CurrentUser.UserProfile.College   = ddlCollege.SelectedValue;
                    CurrentUser.UserProfile.Major     = ddlMajors.SelectedValue;
                    CurrentUser.UserProfile.UpdatedBy = CurrentUser.Email;
                    Result <UserProfile> userProfileResult = ups.UpdateUserProfile(CurrentUser.UserProfile);
                    message = userProfileResult.message;
                    if (userProfileResult.isSuccess)
                    {
                        CurrentUser.UserProfile = userProfileResult.resultObject;

                        IUserManagementService um = new UserManagementService();

                        if (chkrole.Items[0].Selected && !AccessManagementValidator.UserHasRole(CurrentUser, Roles.Student))
                        {
                            // selected student box AND he is not a student already
                            Result <object> AssignRole = um.AssignRole(CurrentUser.Email, (int)Roles.Student);

                            if (AssignRole.isSuccess)
                            {
                                message += "\nStudent role added";
                            }

                            else
                            {
                                message += "\nFailed to add student role";
                            }
                        }

                        if (!chkrole.Items[0].Selected && AccessManagementValidator.UserHasRole(CurrentUser, Roles.Student))
                        {
                            // UNselected student box AND he IS a student then remove this role
                            Result <object> DeAssignRole = um.DeAssignRole(CurrentUser.Email, (int)Roles.Student);

                            if (DeAssignRole.isSuccess)
                            {
                                message += "\nStudent role deassigned successfuly";
                            }

                            else
                            {
                                message += "\nFailed to deassign student role";
                            }
                        }

                        if (chkrole.Items[1].Selected && !AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor))
                        {
                            //selected tutor box AND he is not a tutor already
                            Result <object> AssignRole = um.AssignRole(CurrentUser.Email, (int)Roles.Tutor);

                            if (AssignRole.isSuccess)
                            {
                                AssignRole.message += "\nTutor role added";
                            }

                            else
                            {
                                AssignRole.message += "\nFailed to add tutor role";
                            }
                        }

                        if (!chkrole.Items[1].Selected && AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor))
                        {
                            // UNselected tutor box AND he IS a Tutor then remove this role
                            Result <object> DeAssignRole = um.DeAssignRole(CurrentUser.Email, (int)Roles.Tutor);

                            if (DeAssignRole.isSuccess)
                            {
                                message += "\nTutor role deassigned successfuly";
                            }

                            else
                            {
                                message += "\nFailed to deassign Tutor role";
                            }
                        }
                        CurrentUser = um.GetUser(CurrentUser.Email).resultObject;
                    }

                    ShowMessage(message);
                }
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsLoggedIn)
            {
                if (!IsPostBack)
                {
                    Result <UserProfile> result = ups.GetUserProfile(CurrentUser.Email);
                    if (result.isSuccess)
                    {
                        CurrentUser.UserProfile = result.resultObject;
                    }

                    txtUserEmail.Text = CurrentUser.Email;
                    txtFirstName.Text = CurrentUser.UserProfile.FirstName;
                    txtLastName.Text  = CurrentUser.UserProfile.LastName;

                    CatalogManagementService cms           = new CatalogManagementService();
                    Result <List <String> >  serviceResult = null;
                    serviceResult = cms.GetCatalogDescriptionsByCategory("Majors");
                    if (serviceResult.isSuccess)
                    {
                        ddlMajors.DataSource = serviceResult.resultObject;
                        ddlMajors.DataBind();
                        ddlMajors.Items.Insert(0, new ListItem()
                        {
                            Text = "Select Major...", Value = string.Empty
                        });
                        ddlMajors.SelectedIndex = -1;
                    }

                    serviceResult = cms.GetCatalogDescriptionsByCategory("Colleges");
                    if (serviceResult.isSuccess)
                    {
                        ddlCollege.DataSource = serviceResult.resultObject;
                        ddlCollege.DataBind();


                        ddlCollege.Items.Insert(0, new ListItem()
                        {
                            Text = "Select College...", Value = string.Empty
                        });
                        ddlCollege.SelectedIndex = 0;
                    }
                    ddlMajors.SelectedValue  = CurrentUser.UserProfile.Major;
                    ddlCollege.SelectedValue = CurrentUser.UserProfile.College;

                    chkrole.Items[0].Selected = AccessManagementValidator.UserHasRole(CurrentUser, Roles.Student);
                    chkrole.Items[1].Selected = AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor);
                }

                if (!AccessManagementValidator.UserHasRole(CurrentUser, Roles.Tutor))
                {
                    ratingDiv.Visible = false;
                }
                else
                {
                    IRatingManagementService tr           = new RatingManagementService();
                    Result <TutorsRating>    ratingResult = tr.GetTutorRate(CurrentUser.Email);
                    if (ratingResult.isSuccess)
                    {
                        if (ratingResult.resultObject.Rate == null)
                        {
                            rateTutor.CurrentRating = 0;
                        }
                        else
                        {
                            rateTutor.CurrentRating = (int)ratingResult.resultObject.Rate;
                        }
                    }
                }
            }
        }