Пример #1
0
        private void FilterSessions()
        {
            if (_sessionRepository.GetAll().Count == 0)
            {
                return;
            }

            var gameTypes = _sessionRepository.GetAllGameTypes().OrderByDescending(gt => gt.Name).ToList();

            FilterViewModel.SetWrappedGameTypes(gameTypes);
            FilterViewModel.SetFilter(Filter);
            if (FilterViewModel.StartDate == null && FilterViewModel.EndDate == null)
            {
                UpdateFilterDates();
            }

            _filterWindowService.ShowWindow(FilterViewModel);

            var selectedGameTypes = FilterViewModel.GameTypes
                                    .Where(gt => gt.IsSelected)
                                    .Select(gt => gt.GameType);

            Filter = new CashGameFilter
            {
                GameTypes = new List <GameType>(selectedGameTypes),
                StartDate = FilterViewModel.StartDate,
                EndDate   = FilterViewModel.EndDate
            };

            PlayingSessions = _sessionRepository.GetFilteredPlayingSessions(Filter);
            ShowSessionsOnly();
        }
Пример #2
0
        public void SetFilter(CashGameFilter filter)
        {
            if (filter.GameTypes == null)
            {
                return;
            }

            foreach (var gameType in GameTypes)
            {
                if (filter.GameTypes.Contains(gameType.GameType))
                {
                    gameType.IsSelected = true;
                }
                else
                {
                    gameType.IsSelected = false;
                }
            }

            if (filter.StartDate != null)
            {
                StartDate = filter.StartDate.Value;
            }
            if (filter.EndDate != null)
            {
                EndDate = filter.EndDate.Value;
            }
        }
Пример #3
0
        public CashGameViewModel(ICashGameService cashGameService,
                                 ISessionRepository sessionRepository,
                                 IOpenFileDialogService openFileDialogService,
                                 ISaveFileDialogService saveFileDialogService,
                                 IWaitDialogService waitDialogService,
                                 IFilterWindowService filterWindowService,
                                 IInfoDialogService infoDialogService)
        {
            _cashGameService       = cashGameService;
            _sessionRepository     = sessionRepository;
            _openFileDialogService = openFileDialogService;
            _saveFileDialogService = saveFileDialogService;
            _waitDialogService     = waitDialogService;
            _filterWindowService   = filterWindowService;
            _infoDialogService     = infoDialogService;

            OpenFileCommand         = new RelayCommand(OpenFile);
            FetchFromServerCommand  = new RelayCommand(FetchFromServer);
            ClearCommand            = new RelayCommand(() => UserSessionId = "");
            SaveSessionsCommand     = new RelayCommand(SaveSessions);
            ClearSessionsCommand    = new RelayCommand(ClearSessions);
            ShowSessionsOnlyCommand = new RelayCommand <bool>(ShowSessionsOnly);

            FilterCommand = new RelayCommand(FilterSessions);

            UserSessionId = "Liitä wcusersessionid tähän";

            Messenger.Default.Register <UserSessionIdChangedMessage>(this,
                                                                     message =>
            {
                if (message.Sender != this && message.NewUserSessionId != _userSessionId)
                {
                    UserSessionId = message.NewUserSessionId;
                }
            });

            LoadStoredSessions();

            if (_sessionRepository.GetAll().Count > 0)
            {
                StartDate       = PlayingSessions.Max(s => s.StartTime);
                FilterViewModel = new FilterViewModel(_sessionRepository.GetAll().Min(s => s.StartTime), _sessionRepository.GetAll().Max(s => s.EndTime));
            }
            else
            {
                StartDate       = new DateTime(2010, 11, 1);
                FilterViewModel = new FilterViewModel();
            }

            EndDate = DateTime.Now;
            Filter  = new CashGameFilter();
        }
Пример #4
0
        public IList <Session> GetFilteredSessions(CashGameFilter filter)
        {
            var sessions = _sessions;

            if (filter.GameTypes != null)
            {
                sessions = sessions.Where(s => filter.GameTypes.Contains(s.GameType)).ToList();
            }

            if (filter.StartDate != null)
            {
                sessions = sessions.Where(s => s.StartTime.Date >= filter.StartDate.Value.Date).ToList();
            }

            if (filter.EndDate != null)
            {
                sessions = sessions.Where(s => s.StartTime.Date <= filter.EndDate.Value.Date).ToList();
            }

            return(sessions);
        }
Пример #5
0
        public IList <PlayingSession> GetFilteredPlayingSessions(CashGameFilter filter)
        {
            var sessions = _sessions;

            if (filter.GameTypes != null)
            {
                sessions = _sessions.Where(s => filter.GameTypes.Contains(s.GameType)).ToList();
            }

            var playingSessions = PlayingSession.GroupToPlayingSessions(sessions);

            if (filter.StartDate != null)
            {
                playingSessions = playingSessions.Where(s => s.StartTime.Date >= filter.StartDate.Value.Date).ToList();
            }

            if (filter.EndDate != null)
            {
                playingSessions = playingSessions.Where(s => s.StartTime.Date <= filter.EndDate.Value.Date).ToList();
            }

            return(playingSessions);
        }