Exemplo n.º 1
0
        public static TokenDTO TokenToTokenDTO(this Token param)
        {
            TokenDTO target = new TokenDTO();

            target.TokenId   = param.TokenId;
            target.TokenName = param.TokenName;
            foreach (KeyValuePair <string, string> item in param.Tokens)
            {
                target.Tokens.Add(new TokenForSerialization {
                    Key = item.Key, Value = item.Value
                });
            }

            return(target);
        }
Exemplo n.º 2
0
        public static Token TokenDTOToTokenDomain(this TokenDTO param)
        {
            Token target = new Token();

            target.TokenId   = param.TokenId;
            target.TokenName = param.TokenName;

            foreach (TokenForSerialization item in param.Tokens)
            {
                if (item.Key != null && item.Value != null)
                {
                    target.Tokens.Add(item.Key, item.Value);
                }
            }

            return(target);
        }
        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);
        }