public static Token TokenDAOToTokenDomain(this TokenDAO param)
        {
            Token target = new Token();

            target.TokenId   = param.TokenId;
            target.TokenName = param.TokenName;
            target.Tokens    = param.Token;

            return(target);
        }
        public static TokenDAO TokenToTokenDAO(this Token param)
        {
            TokenDAO target = new TokenDAO();

            target.TokenId   = param.TokenId;
            target.TokenName = param.TokenName;
            target.Token     = param.Tokens;

            return(target);
        }
示例#3
0
        public static IAccountToken GetTokenByID(Int32 tokenId, Sources source)
        {
            IAccountToken targetToken = null;

            using (ISession session = sessionFactory.OpenSession())
            {
                TokenDAO tok   = session.Get <TokenDAO>(tokenId);
                Token    token = tok.TokenDAOToTokenDomain();
                targetToken = GetCurrentInstanceForToken(source);

                if (targetToken != null)
                {
                    targetToken = targetToken.Convert(token);
                }
            }
            return(targetToken);
        }
示例#4
0
        public static IAccountSettings GetAccountByTokenID(Int32 id)
        {
            IAccountSettings targetAccount = null;

            using (ISession session = sessionFactory.OpenSession())
            {
                TokenDAO          token         = session.Get <TokenDAO>(id);
                ServiceAccountDAO accountFromDB = session.Query <ServiceAccountDAO>().Where(x => x.Tokens.Contains(token)).SingleOrDefault();
                if (accountFromDB != null)
                {
                    targetAccount = GetCurrentInstance(accountFromDB.Source);
                    if (targetAccount != null)
                    {
                        ServiceAccount accountDomain = accountFromDB.ServiceAccountDAOToDomain(true);
                        targetAccount = targetAccount.Convert(accountDomain);
                    }
                }
                return(targetAccount);
            }
        }
        public Boolean DeleteToken(TokenDTO token)
        {
            Boolean         succeed        = false;
            ISessionFactory sessionFactory = NhibernateSessionFactory.GetSessionFactory(NhibernateSessionFactory.SessionFactoryConfiguration.Application);
            TokenDAO        target         = token.TokenDTOToTokenDomain().TokenToTokenDAO();

            using (ISession session = sessionFactory.OpenSession())
            {
                ServiceAccountDAO account = session.Query <ServiceAccountDAO>().Where(acount => acount.Tokens.Contains(target)).SingleOrDefault();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Delete(target);
                    transaction.Commit();
                    succeed = transaction.WasCommitted;
                }
                if (succeed)
                {
                    UpdateAccountVersion(account.ServiceAccountId, account.AccountVersion + 1);
                }
            }
            return(succeed);
        }
        public static TokenDAO TokenToTokenDAO(this Token param)
        {
            TokenDAO target = new TokenDAO();

            target.TokenId = param.TokenId;
            target.TokenName = param.TokenName;
            target.Token = param.Tokens;

            return target;
        }