示例#1
0
        private static IEnumerable <TimeWarpUser> GetUsersFromRepository(ITimeWarpStateCalculator timeWarpStateCalculator)
        {
            IList <TimeWarpUserState> userStates;

            //todo: optimize this crap.
            using (var session = new NHibernateSessionPerRequest <TimeWarpUserStateClassMap>())
            {
                var accountRespository = new TimeWarpAccountRepository(session.GetCurrentSession());
                var accounts           = accountRespository.GetAll();

                var userStateRepository = new TimeWarpUserStateRepository(session.GetCurrentSession());

                userStates = new List <TimeWarpUserState>();
                foreach (var account in accounts)
                {
                    var latestState = userStateRepository.GetLatestStateByAccountId(account.Id);
                    if (latestState != null)
                    {
                        NHibernateUtil.Initialize(latestState.Account);
                        userStates.Add(userStateRepository.GetLatestStateByAccountId(account.Id));
                    }
                }
            }

            return(userStates.Select(x => new TimeWarpUser(x, timeWarpStateCalculator)));
        }
示例#2
0
        private static TimeWarpUserState UpdateValuesInDatabase(Account account)
        {
            var repository = new TimeWarpUserStateRepository();
            TimeWarpUserState timeWarpUserState = repository.GetLatestStateByAccountId(account.Id);

            return(timeWarpUserState);
        }