Exemple #1
0
 /// <summary>
 /// Changes the user role.
 /// </summary>
 /// <param name="projectUser">The project user.</param>
 /// <returns></returns>
 private bool ChangeUserRole(Data.ProjectUser projectUser)
 {
     if (projectUser.Role != ucUserInvitationPopup.ProjectRole)
     {
         projectUser.Role = ucUserInvitationPopup.ProjectRole;
         string       projectUserName = projectUser.User.FirstName + " " + projectUser.User.LastName;
         Notification nf = CreateNotification(Support.GetCodeIdByCodeValue("OperationType", "EDIT"), string.Format("{0} edited the project role of {1}.", Support.UserFullName, projectUserName));
         this.GetBL <NotificationBL>().AddNotification(nf, false);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
        /// <summary>
        /// Shows the edit user permission.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projectUserId">The project user identifier.</param>
        public void ShowEditUserPermission(int userId, int projectId, int projectUserId)
        {
            Data.User        user           = this.GetBL <PersonalBL>().GetUser(userId);
            Data.ProjectUser projectUser    = this.GetBL <ProjectBL>().GetProjectUser(projectUserId);
            int  projectAdminUserTypeCodeId = Utils.GetCodeByValue("ProjectUserTypeCode", "PROJADMIN").CodeId;
            int  staffUserTypeCodeId        = Utils.GetCodeByValue("ProjectUserTypeCode", "STAFF").CodeId;
            int  observerUserTypeCodeId     = Utils.GetCodeByValue("ProjectUserTypeCode", "OBSERVER").CodeId;
            bool isProjectAdmin             = projectUser.ProjectUserTypeCodeId == projectAdminUserTypeCodeId;

            if (isProjectAdmin)
            {
                radioProjectAdmin.Enabled    = false;
                radioProjectObserver.Enabled = false;
                radioProjectStaff.Enabled    = false;
            }
            else
            {
                radioProjectAdmin.Enabled    = true;
                radioProjectObserver.Enabled = true;
                radioProjectStaff.Enabled    = true;
            }

            ltrlProjectTeamInvitationText.Text = string.Format("Change '{0}' permission settings for this Project.", (user.FirstName + " " + user.LastName));
            trProjInviteName.Visible           = false;
            txtProjectRole.Text          = string.Empty;
            radioProjectAdmin.Checked    = isProjectAdmin;
            radioProjectStaff.Checked    = projectUser.ProjectUserTypeCodeId == staffUserTypeCodeId;
            radioProjectObserver.Checked = projectUser.ProjectUserTypeCodeId == observerUserTypeCodeId;
            txtProjectRole.Text          = projectUser.Role;
            chkBudgetSummary.Checked     = projectUser.CanSeeBudgetSummary;

            bool isAdmin = isProjectAdmin || Support.IsCompanyAdministrator(Support.GetCompanyByProjectId(projectId).CompanyId, userId);

            this.IsAdmin = isAdmin;
            if (IsAdmin)
            {
                chkBudgetSummary.Enabled = false;
                chkBudgetSummary.Checked = true;
            }
            else
            {
                chkBudgetSummary.Enabled = true;
            }
            RegisterScriptForPermissionSelection();
        }
Exemple #3
0
        /// <summary>
        /// Handles the Click event of the btnApplyUserPermission control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnApplyUserPermission_Click(object sender, EventArgs e)
        {
            if (!StopProcessing)
            {
                int projectUserId             = int.Parse(btnApplyUserPermission.CommandArgument);
                int selectedUserTypeCodeId    = ucUserInvitationPopup.SelectedUserType;
                int projectAdminTypeCodeId    = Support.GetCodeIdByCodeValue("ProjectUserTypeCode", "PROJADMIN");
                Data.ProjectUser projectUser  = this.GetBL <ProjectBL>().GetProjectUser(projectUserId);
                bool             shouldCommit = false;

                #region ChangePermission

                if (projectUser.ProjectUserTypeCodeId != selectedUserTypeCodeId)
                {
                    if (selectedUserTypeCodeId == projectAdminTypeCodeId)
                    {
                        if (Support.IsCompanyAdministrator(Support.GetCompanyByProjectId(ProjectId).CompanyId))
                        {
                            divProjectAdminConfirmMessage.Visible = false;
                        }
                        else
                        {
                            divProjectAdminConfirmMessage.Visible   = true;
                            divProjectAdminConfirmMessage.InnerText = "(If you say 'Yes', you will lose the ability to make any further changes to the project team.)";
                        }
                        NewAdminUserId = projectUserId;
                        popupProjectAdminConfirmation.ShowPopup(1001);
                        return;
                    }
                    else
                    {
                        projectUser.ProjectUserTypeCodeId = selectedUserTypeCodeId;
                        projectUser.LastUpdatedByUserId   = UserID;
                        projectUser.LastUpdatedDate       = Now;
                        //Create Notification for changing permission of the project

                        #region Project Notification

                        string       projectUserName = projectUser.User.FirstName + " " + projectUser.User.LastName;
                        Notification nf = CreateNotification(Support.GetCodeIdByCodeValue("OperationType", "EDIT"), string.Format("{0} changed the project permission of {1}.", Support.UserFullName, projectUserName));
                        this.GetBL <NotificationBL>().AddNotification(nf, false);
                        shouldCommit = true;

                        #endregion Project Notification
                    }
                }

                #endregion ChangePermission

                #region ChangeRole

                shouldCommit = ChangeUserRole(projectUser) || shouldCommit;

                #endregion ChangeRole

                #region ChanageBudgetSummaryPermission

                if (projectUser.CanSeeBudgetSummary != ucUserInvitationPopup.IsBudgetSummaryChecked)
                {
                    projectUser.CanSeeBudgetSummary = ucUserInvitationPopup.IsBudgetSummaryChecked;
                    projectUser.LastUpdatedByUserId = UserID;
                    projectUser.LastUpdatedDate     = Now;
                    shouldCommit = true;
                }

                #endregion ChanageBudgetSummaryPermission

                if (shouldCommit)
                {
                    this.GetBL <BaseBL>().SaveChanges();
                }
                popupEditUserPermission.HidePopup();
                LoadProjectTeam();
            }
        }