Exemplo n.º 1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.Exception">Permission denied.</exception>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                User user = DataContext.Users.Where(u => u.UserId == ViewUserId).FirstOrDefault();

                #region Permission check and Set Read Only flag

                //If the viewing-user is the currently logged in user load the page in edit mode.
                //Else if the viewing user is in contacts of the logged-in user, load the page in readonly mode.
                //Else throw 'no permission' exception

                if (ViewUserId == UserID)
                {
                    IsReadOnly = false;
                }
                else
                {
                    if (!Support.CanAccessUser(user))
                    {
                        throw new Exception("Permission denied.");
                    }
                    else
                    {
                        IsReadOnly = true;
                    }
                }

                #endregion Permission check and Set Read Only flag

                DisplayTitle             = IsReadOnly ? "User Details" : "Personal Profile";
                divPrivacyNotice.Visible = !IsReadOnly;

                if (!IsReadOnly)
                {
                    pnlPersonalDetails.DefaultButton = "btnSavePersonalDetails";
                }

                #region Setup Image Upload control

                //Setup image upload control
                upnlImageUpload.Visible = !IsReadOnly;
                if (!IsReadOnly)
                {
                    fileUpload.RelatedTableName = "User";
                    fileUpload.RelatedId        = ViewUserId;
                    fileUpload.UploadMediaType  = UserWeb.Controls.Common.FileUpload.MediaType.Images;
                    fileUpload.IsReadOnly       = IsReadOnly;
                    fileUpload.LoadUI();
                }

                #endregion Setup Image Upload control

                LoadData(user);

                userProjects.ViewUserId = ViewUserId;
                userProjects.LoadData();

                userSkills.ViewUserId = ViewUserId;
                userSkills.IsReadOnly = IsReadOnly;
                userSkills.LoadData();

                sbUserEmailNotifications.ViewUserId = UserID;
                sbUserEmailNotifications.IsReadOnly = IsReadOnly;
                sbUserEmailNotifications.LoadData();

                LoadBreadCrumbs();
            }
        }