Inheritance: System.Entity
示例#1
0
        /// <summary>
        /// Create a empty user profile
        /// </summary>
        /// <param name="username"></param>
        /// <param name="isAuthenticated"></param>
        private void CreateProfileForUser(string username, bool isAuthenticated)
        {
            if (ProfileExists(username))
                throw new ProviderException(string.Format(CultureInfo.InvariantCulture, "ProfileAlreadyExists {1}", username));

            using (var s = NHOpenIDMembershipProvider.GetNHibernateSession())
            {
                using (s.BeginTransaction())
                {
                    var c = s.CreateCriteria<User>();
                    c.Add(Expression.Eq("Username", username));
                    c.Add(Expression.Eq("ApplicationName", m_applicationName));
                    var user = c.UniqueResult<User>();
                    if (user != null)
                    {
                        Profile p = new Profile();
                        p.ApplicationName = m_applicationName;
                        p.IsAnonymous = !isAuthenticated;
                        p.LastActivityDate = DateTime.Now;
                        p.LastUpdatedDate = DateTime.Now;
                        s.Save(p);
                        user.SetProfile(p);
                    }
                    s.Transaction.Commit();
                }
            }
        }
示例#2
0
文件: Users.cs 项目: sztupy/shaml
 public virtual void SetProfile(Profile profile)
 {
     UserProfile = profile;
     UserProfile.User = this;
 }