public ActionResult AjaxUserProfile(UserProfileModel model)
 {
     try
     {
         HttpContext.Profile["nickname"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.NickName) ? "" : model.NickName);
         HttpContext.Profile["signature"] = WebUtils.ubb2html(string.IsNullOrWhiteSpace(model.Signature) ? "" : model.Signature);
         HttpContext.Profile["intro"] = WebUtils.ubb2html(string.IsNullOrWhiteSpace(model.Intro) ? "" : model.Intro);
         HttpContext.Profile["gender"] = model.Gender;
         HttpContext.Profile["Department"] = model.Department.ToString();
         HttpContext.Profile["birth"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Birth) ? "" : model.Birth);
         HttpContext.Profile["location"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Location) ? "" : model.Location);
         HttpContext.Profile["website"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Website) ? "" : model.Website);
         HttpContext.Profile["qq"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.QQ) ? "" : model.QQ);
         HttpContext.Profile["sina"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Sina) ? "" : model.Sina);
         HttpContext.Profile["facebook"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Facebook) ? "" : model.Facebook);
         HttpContext.Profile["twitter"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Twitter) ? "" : model.Twitter);
         HttpContext.Profile["medals"] = string.IsNullOrWhiteSpace(model.Medals) ? "" : model.Medals;
         HttpContext.Profile["phone"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Phone) ? "" : model.Phone);
         HttpContext.Profile["email"] = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Email) ? "" : model.Email);
         HttpContext.Profile["isSendEmail"] = model.IsSendEmail;
         return Content("0", "text/html;charset=UTF-8");
     }
     catch
     {
         return Content("1", "text/html;charset=UTF-8");
     }
 }
Пример #2
0
        /// <summary>
        /// 获取当前用户Profile
        /// </summary>
        private UserProfileModel GetMyProfile()
        {
            UserProfileModel userprofile = new UserProfileModel();
            try
            {
                userprofile.NickName = GetProfileItem("nickname");
                userprofile.Signature = GetProfileItem("signature");
                userprofile.Intro = GetProfileItem("intro");
                userprofile.Gender = GetProfileItem("gender", "1");
                userprofile.Department = GetProfileItem("Department", "00000000-0000-0000-0000-000000000000");
                userprofile.Birth = GetProfileItem("birth");
                userprofile.Location = GetProfileItem("location");
                userprofile.Website = GetProfileItem("website");
                userprofile.QQ = GetProfileItem("qq");
                userprofile.Sina = GetProfileItem("sina");
                userprofile.Facebook = GetProfileItem("facebook");
                userprofile.Twitter = GetProfileItem("twitter");
                userprofile.Medals = GetProfileItem("medals");
                userprofile.Phone = GetProfileItem("phone");

                string email = GetProfileItem("email");
                if (string.IsNullOrEmpty(email))
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, false /* userIsOnline */);
                    userprofile.Email = currentUser.Email;
                }
                else
                {
                    userprofile.Email = email;
                }
                userprofile.IsSendEmail = GetProfileItem("isSendEmail", "1");
            }
            catch
            { }
            return userprofile;
        }
        /// <summary>
        /// 获取用户Profile
        /// </summary>
        private UserProfileModel GetUserProfile(string user)
        {
            UserProfileModel userprofile = new UserProfileModel();
            try
            {
                ProfileBase objProfile = System.Web.Profile.ProfileBase.Create(user);

                userprofile.NickName = GetUserProfileItem(objProfile, "nickname");
                userprofile.Signature = GetUserProfileItem(objProfile, "signature");
                userprofile.Intro = GetUserProfileItem(objProfile, "intro");
                userprofile.Gender = GetUserProfileItem(objProfile, "gender", "1");
                userprofile.Department = GetUserProfileItem(objProfile, "Department", "00000000-0000-0000-0000-000000000000");
                userprofile.Birth = GetUserProfileItem(objProfile, "birth");
                userprofile.Location = GetUserProfileItem(objProfile, "location");
                userprofile.Website = GetUserProfileItem(objProfile, "website");
                userprofile.QQ = GetUserProfileItem(objProfile, "qq");
                userprofile.Sina = GetUserProfileItem(objProfile, "sina");
                userprofile.Facebook = GetUserProfileItem(objProfile, "facebook");
                userprofile.Twitter = GetUserProfileItem(objProfile, "twitter");
                userprofile.Medals = GetUserProfileItem(objProfile, "medals");
                userprofile.Phone = GetUserProfileItem(objProfile, "phone");

                string email = GetUserProfileItem(objProfile, "email");
                if (string.IsNullOrEmpty(email))
                {
                    MembershipUser currentUser = Membership.GetUser(user.Trim(), false /* userIsOnline */);
                    userprofile.Email = currentUser.Email;
                }
                else
                {
                    userprofile.Email = email;
                }
                userprofile.IsSendEmail = GetUserProfileItem(objProfile, "isSendEmail", "1");
            }
            catch
            { }
            return userprofile;
        }