Exemplo n.º 1
0
        private TimeWarpUserState SaveNewState(Account account, DateTime time, TimeWarpState timeWarpState, int agentType)
        {
            var updatedState = new TimeWarpUserState(account, timeWarpState, time, TimeSpan.Zero, 0.0, agentType);

            _userStateRepository.Add(updatedState);
            return(updatedState);
        }
Exemplo n.º 2
0
        public bool TryGetCurrentState(long accountId, DateTime time, out TimeWarpUserState timeWarpUserState)
        {
            var currentState = _userStateRepository.GetLatestStateByAccountId(accountId);

            if (currentState == null)
            {
                timeWarpUserState = null;
                return(false);
            }
            timeWarpUserState = _timeWarpStateCalculator.RecalculateTimeWarpState(currentState, time);
            return(true);
        }
Exemplo n.º 3
0
 public TimeWarpUserState StartRest(DateTime time)
 {
     _timeWarpUserState = new TimeWarpUserState(Account, TimeWarpState.Resting, time, TimeSpan.Zero, 0.0);
     return(_timeWarpUserState);
 }
Exemplo n.º 4
0
 public TimeWarpUser(TimeWarpUserState state, ITimeWarpStateCalculator timeWarpStateCalculator)
 {
     Account = state.Account;
     _timeWarpStateCalculator = timeWarpStateCalculator;
     _timeWarpUserState       = state;
 }