示例#1
0
    /// <summary>
    /// After dvUserInfo data binding.
    /// </summary>
    /// <param name="sender">Object sender : dvUserInfo.</param>
    /// <param name="e">EventArgs e.</param>
    protected void OnUserInfoDataBound(Object sender, EventArgs e)
    {
        Address      address      = AddressRepository.GetUserAddress(this._userID);
        PersonalInfo personalInfo = PersonalInfoRepository.GetUserInfo(this._userID);

        #region // Inner controls
        Label lblBirthday  = dvUserInfo.FindControl("lblBirthday") as Label;
        Label lblPhone     = dvUserInfo.FindControl("lblPhone") as Label;
        Label lblSex       = dvUserInfo.FindControl("lblSex") as Label;
        Label lblCountry   = dvUserInfo.FindControl("lblCountry") as Label;
        Label lblCity      = dvUserInfo.FindControl("lblCity") as Label;
        Label lblArea      = dvUserInfo.FindControl("lblArea") as Label;
        Label lblStreet    = dvUserInfo.FindControl("lblStreet") as Label;
        Label lblHome      = dvUserInfo.FindControl("lblHome") as Label;
        Label lblApartment = dvUserInfo.FindControl("lblApartment") as Label;
        #endregion

        imgUserAvatar.ImageUrl = personalInfo.ImagePath;
        if (this.imgUserAvatar.ImageUrl == Constants._defaultAvatarImage)
        {
            this.imgUserAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, Constants._defaultAvatarImage);
        }
        else
        {
            this.imgUserAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, imgUserAvatar.ImageUrl);
        }

        // If user have address -> set values to controls.
        if (address != null)
        {
            this.SetValueOrInvisible(
                this.dvUserInfo,
                0,
                lblBirthday,
                String.Format("{0:" + Constants._dateFormat + "}", personalInfo.Birthday));

            if (this.SetValueOrInvisible(this.dvUserInfo, 1, lblSex, personalInfo.Sex.ToString()))
            {
                lblSex.Text = EnumsHelper.ToString((Sex)Convert.ToInt32(lblSex.Text));
            }
            this.SetValueOrInvisible(this.dvUserInfo, 2, lblPhone, personalInfo.Phone);
            Guid?countryID = address.CountryID;
            if (countryID != null)
            {
                this.SetValueOrInvisible(
                    this.dvUserInfo, 3, lblCountry, AddressRepository.GetCountryName((Guid)countryID));
            }
            Guid?cityID = address.CityID;
            if (cityID != null)
            {
                this.SetValueOrInvisible(
                    this.dvUserInfo, 4, lblCity, AddressRepository.GetCityName((Guid)cityID));
            }
            this.SetValueOrInvisible(this.dvUserInfo, 5, lblArea, address.Area);
            this.SetValueOrInvisible(this.dvUserInfo, 6, lblStreet, address.Street);
            this.SetValueOrInvisible(this.dvUserInfo, 7, lblHome, address.Home);
            this.SetValueOrInvisible(this.dvUserInfo, 8, lblApartment, address.Apartment);
        }
    }
示例#2
0
 private void FillMessageInfo(RepeaterItem item, LinkButton btnUserName)
 {
     if (btnUserName != null)
     {
         PersonalInfo person = PersonalInfoRepository.GetUserInfo(Guid.Parse(btnUserName.Text));
         btnUserName.Text = String.Join(" ", person.FirstName, person.LastName);
     }
 }
示例#3
0
        public List <KeyValuePair <Guid, String> > GetAllFriends(Guid userID)
        {
            var friendList = FriendRepository.GetUserFriends(userID);

            return(friendList
                   .Select(s => new KeyValuePair <Guid, String>(
                               s.FriendID,
                               PersonalInfoRepository.GetUserInfo(s.FriendID).LastName)).ToList());
        }
示例#4
0
    /// <summary>
    /// Bind data to wallboard.
    /// </summary>
    /// <param name="sender">Object sender : GridView.</param>
    /// <param name="e">GridViewRowEventArgs e.</param>
    protected void OnWallRowDataBound(Object sender, GridViewRowEventArgs e)
    {
        GridViewRow grdRowItem = e.Row;

        // Get user names on wallboard by id.
        Label        lblFromID    = grdRowItem.FindControl("lblFromID") as Label;
        PersonalInfo personalInfo = PersonalInfoRepository.GetUserInfo(this._userID);

        if (lblFromID != null && personalInfo != null)
        {
            Guid fromID = Guid.Parse(lblFromID.Text);
            lblFromID.Text = String.Join(" ", personalInfo.FirstName, personalInfo.LastName);
        }
    }
        public String GetUploadedAvatarImage(Guid?id = null)
        {
            HttpContext.Current.Session["_userID"] = "e80cd2ac-8517-4e95-8321-3f4593d2106a";

            //Guid userID = (id == null) ? Guid.Empty : (Guid)id;

            Guid userID = (id == Guid.Empty) ? Guid.Empty : (Guid)id;

            if (userID == Guid.Empty)
            {
                if (Guid.TryParse((String)Session["_userID"], out userID))
                {
                    return(PersonalInfoRepository.GetUserInfo(userID).ImagePath);
                }
            }
            else
            {
                return(PersonalInfoRepository.GetUserInfo(userID).ImagePath);
            }

            return(_defaultAvatarImage);
        }
示例#6
0
 /// <summary>
 /// PageLoad event handler.
 /// </summary>
 /// <param name="sender">Object sender.</param>
 /// <param name="e">EventArgs e.</param>
 protected void Page_Load(Object sender, EventArgs e)
 {
     Guid.TryParse("e80cd2ac-8517-4e95-8321-3f4593d2106a", out this._userID);
     if (!Page.IsPostBack)
     {
         PersonalInfo personalInfo = PersonalInfoRepository.GetUserInfo(this._userID);
         fvMain.DataSource = new List <PersonalInfo> {
             personalInfo
         };
         fvAddress.DataSource = new List <Address> {
             AddressRepository.GetUserAddress(this._userID)
         };
         imgAvatar.ImageUrl = personalInfo.ImagePath;
         if (this.imgAvatar.ImageUrl == Constants._defaultAvatarImage)
         {
             imgAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, Constants._defaultAvatarImage);
         }
         else
         {
             this.imgAvatar.ImageUrl = String.Concat(Constants._defaultPhotoPath, imgAvatar.ImageUrl);
         }
         Page.DataBind();
     }
 }
示例#7
0
    /// <summary>
    /// Page_Load event.
    /// </summary>
    /// <param name="sender">Object sender.</param>
    /// <param name="e">EventArgs e.</param>
    protected void Page_Load(Object sender, EventArgs e)
    {
        if (!SessionHelper.IsAuthenticated)
        {
            Response.Redirect("~/Login.aspx");
        }
        this._userID = new Guid(Request.QueryString["id"].ToString());
        if (_userID != SessionHelper.UserID)
        {
            //invisible and visible needled things...
        }
        if (SessionHelper.IsModerator)
        {
            //visible needled things
            Button btnBan = (Button)Master.FindControl("btnBan");
            btnBan.Visible = true;
        }
        if (SessionHelper.IsAdmin)
        {
            //visible needled things
            Label lblEmail = (Label)Master.FindControl("lblEmail");
            lblEmail.Text    = (UserRepository.GetUserInfo(this._userID)).Email;
            lblEmail.Visible = true;
            ImageButton btnBan = (ImageButton)Master.FindControl("btnBan");
            btnBan.Visible = true;
            ImageButton btnAdmin = (ImageButton)Master.FindControl("btnAdmin");
            btnAdmin.Visible = true;
        }
        // Тут должен быть идентификатор текущего пользователя
        this._userID = new Guid(Request.QueryString["id"].ToString());
        //Guid.Parse("e80cd2ac-8517-4e95-8321-3f4593d2106a");

        if (!Page.IsPostBack)
        {
            // Set user name and status on the top of table.
            PersonalInfo personalInfo = PersonalInfoRepository.GetUserInfo(this._userID);
            if (personalInfo != null)
            {
                dvUserInfo.DataSource = new List <PersonalInfo> {
                    personalInfo
                };
                lblHeadUserName.Text   = String.Join(" ", personalInfo.FirstName, personalInfo.LastName);
                lblHeadUserStatus.Text = EnumsHelper.ToString(((UserStatus)StatusRepository.GetStatusID(this._userID)));

                // Show user full name.
                lblUserName.Text = String.Join(
                    " ",
                    personalInfo.FirstName,
                    personalInfo.LastName,
                    personalInfo.MiddleName,
                    personalInfo.NickName);

                // Show status message.
                btnStatusMessage.Text = StatusRepository.GetStatusMessage(this._userID);
                if (btnStatusMessage.Text == String.Empty)
                {
                    btnStatusMessage.Text = _defaultEmptyStatusMessage;
                }
            }

            // Bind data to wallboard.
            IEnumerable <WallBoardItem> dsWallBoardItem = WallBoardItemRepository.GetUserWallboardItems(this._userID);
            fvWall.DataSource  = dsWallBoardItem;
            grdWall.DataSource = dsWallBoardItem;

            // Bind all page data elements.
            Page.DataBind();
        }

        // Set invisible mode to status change panel on postback.
        if (Page.IsPostBack)
        {
            this.StatusPanelEditMode(false);
        }
    }