Beispiel #1
0
        private UserAccounts GetOne(int userId)
        {
            var dbSession = DbSessionFactory.GetCurrentSession();
            var result    = dbSession.UserAccountsRepository.LoadEntities(s => s.UserId == userId).SingleOrDefault();

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new UserAccounts()
                {
                    UserId = userId
                };
                dbSession.UserAccountsRepository.AddEntities(result);
                if (dbSession.SaveChange() > 0)
                {
                    return(result);
                }
                else
                {
                    throw new Exception("更新条目出错");
                }
            }
        }
Beispiel #2
0
        public bool SetPassword(string password)
        {
            var dataSource = GetOne(this._userId);

            dataSource.Password = password;
            dataSource.IsActive = true;
            return(DbSessionFactory.GetCurrentSession().SaveChange() > 0);
        }