Example #1
0
        public ProfileHelper(string id)
        {
            if (SecurityContext.IsAuthenticated)
            {
                id       = String.IsNullOrEmpty(id) ? SecurityContext.CurrentAccount.ID.ToString() : id;
                _ownInfo = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            }

            if (!String.IsNullOrEmpty(id))
            {
                _userInfo = CoreContext.UserManager.GetUserByUserName(id);
            }

            if (_userInfo == null || _userInfo == Constants.LostUser)
            {
                if (!String.IsNullOrEmpty(id))
                {
                    try
                    {
                        _userID = new Guid(id);
                    }
                    catch
                    {
                        _userID = SecurityContext.CurrentAccount.ID;
                    }
                }

                if (!CoreContext.UserManager.UserExists(_userID))
                {
                    _userID = SecurityContext.CurrentAccount.ID;
                }
                _userInfo = CoreContext.UserManager.GetUsers(_userID);
            }
            else
            {
                _userID = _userInfo.ID;
            }

            userProfile = new MyUserProfile(_userID);
        }
        public ProfileHelper(string id)
        {
            if (SecurityContext.IsAuthenticated)
            {
                id = String.IsNullOrEmpty(id) ? SecurityContext.CurrentAccount.ID.ToString() : id;
                _ownInfo = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            }

            if (!String.IsNullOrEmpty(id))
            {
                _userInfo = CoreContext.UserManager.GetUserByUserName(id);
            }

            if (_userInfo == null || _userInfo == Constants.LostUser)
            {
                if (!String.IsNullOrEmpty(id))
                {
                    try
                    {
                        _userID = new Guid(id);
                    }
                    catch
                    {
                        _userID = SecurityContext.CurrentAccount.ID;
                    }
                }

                if (!CoreContext.UserManager.UserExists(_userID))
                {
                    _userID = SecurityContext.CurrentAccount.ID;
                }
                _userInfo = CoreContext.UserManager.GetUsers(_userID);
            }
            else
            {
                _userID = _userInfo.ID;
            }

            userProfile = new MyUserProfile(_userID);
        }