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()); }
private PomodoroSession CreatePomodoroSessionForTests() { PomodoroSession session = new PomodoroSession(); session.Date = DateTime.Today; session.Duration = 1500; session.Title = "TEST"; return(session); }
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); }
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); }
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(); } ); }