Beispiel #1
0
        public static List <IAccountSettings> GetAllAccounts()
        {
            List <IAccountSettings> allUserAccounts = new List <IAccountSettings>();

            using (ISession session = sessionFactory.OpenSession())
            {
                var allUserLinks = session.QueryOver <UserLinkDAO>().List();
                if (allUserLinks != null)
                {
                    List <ServiceAccountDAO> allUserAccountsDAO = allUserLinks.Select <UserLinkDAO, ServiceAccountDAO>(x => x.Account).ToList();
                    List <ServiceAccount>    allUserAc          = SettingsConverter.ServiceAccountDAOCollectionToDomain(allUserAccountsDAO);
                    foreach (ServiceAccount account in allUserAc)
                    {
                        IAccountSettings temp = GetCurrentInstance(account.Source);

                        allUserAccounts.Add(temp.Convert(account));
                    }
                }
                else
                {
                    allUserAccounts = null;
                }

                return(allUserAccounts);
            }
        }
        private List <ServiceAccountDTO> AllUserAccountsByUserID(Int32 userId, Boolean owner)
        {
            List <ServiceAccountDTO> allUserAccountsDTO;

            ISessionFactory sessionFactory = NhibernateSessionFactory.GetSessionFactory(NhibernateSessionFactory.SessionFactoryConfiguration.Application);

            using (ISession session = sessionFactory.OpenSession())
            {
                var allUserLinks = session.QueryOver <UserLinkDAO>().Where(x => x.UserId == userId).And(link => link.Owner == owner).List();
                if (allUserLinks != null)
                {
                    List <ServiceAccountDAO> allUserAccountsDAO = allUserLinks.Select <UserLinkDAO, ServiceAccountDAO>(x => x.Account).ToList();
                    List <ServiceAccount>    alAcc = SettingsConverter.ServiceAccountDAOCollectionToDomain(allUserAccountsDAO);
                    allUserAccountsDTO = SettingsConverter.ServiceAccountDomainCollectionToDTO(alAcc);
                }
                else
                {
                    allUserAccountsDTO = null;
                }

                return(allUserAccountsDTO);
            }
        }