예제 #1
0
        public AccountOBJ GetAccount(AccountOBJ entity, bool AutoCreate = false)
        {
            IDbEntity that = Get(entity);

            if (that != null)
            {
                return((AccountOBJ)that);
            }

            CHeck();
            Users usr = session.QueryOver <Users>().Where(x => x.UserName == entity.Username).List().FirstOrDefault();

            if (usr != null)
            {
                AccountOBJ account = GetAccountFromDB(usr.UserName);
                ENTITY.Add(account.GetId(), account);
                return(account);
            }
            else
            {
                if (AutoCreate)
                {
                    AccountOBJ user = new AccountOBJ((Users)entity.GetEntity());
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        user.Id = (uint)session.Save(user.GetEntity());
                        transaction.Commit();
                    }
                    return(GetAccount(user));
                }
            }
            return(null);
        }
예제 #2
0
        private IDbEntity Get(AccountOBJ entity)
        {
            if (ENTITY.TryGetValue(entity.GetId(), out IDbEntity Entity))
            {
                return(Entity);
            }

            return(null);
        }