Пример #1
0
        public Task <bool> UpdateSessionInfo(PomodoroSession currentSession)
        {
            var preValue = StorageModel.Sessions.SingleOrDefault((x) => x.Id == currentSession.Id);

            StorageModel.Sessions.RemoveAll((x) => x.Id == currentSession.Id);

            StorageModel.Sessions.Add(currentSession);

            return(SaveAsync());
        }
Пример #2
0
        private PomodoroSession CreatePomodoroSessionForTests()
        {
            PomodoroSession session = new PomodoroSession();

            session.Date     = DateTime.Today;
            session.Duration = 1500;
            session.Title    = "TEST";

            return(session);
        }
Пример #3
0
        public async void SavePomodoroToFileAsync()
        {
            StorageFile file = await TimerViewModel.GetSaveFileAsync();

            PomodoroSession session = CreatePomodoroSessionForTests();

            await FileIO.AppendTextAsync(file, session.Serialize());

            string content = await FileIO.ReadTextAsync(file);

            string expected = "TEST," + DateTime.Today.ToString() + ",1500";

            Assert.AreEqual(expected, content);
        }
Пример #4
0
        public PomodoroSession GetSession()
        {
            var todaySession = StorageModel.Sessions.SingleOrDefault((x) => x.Day == DateTime.Today);

            if (todaySession == null)
            {
                todaySession = new PomodoroSession()
                {
                    Day = DateTime.Today
                };
                StorageModel.Sessions.Add(todaySession);
            }

            return(todaySession);
        }
Пример #5
0
        public TimerViewModel()
        {
            CurrentSession = new PomodoroSession();

            Pomodoro = new Pomodoro(10, 5);
            Display  = Pomodoro.TimeString();

            Pomodoro.IntervalComplete += OnIntervalComplete;
            Pomodoro.StateChanged     += OnTimerStateChanged;
            Pomodoro.ModeChanged      += OnPomodoroChanged;

            ToggleStartCommand = new JFCommand(
                _ => true,
                _ => { ToggleTimer(); }
                );

            CancelTimerCommand = new JFCommand(
                _ => Pomodoro.State != TimerServiceState.Stopped,
                _ => { StopTimer(); }
                );
        }