コード例 #1
0
 public void AddPomodoro(Pomodoro pomodoro)
 {
     IEnumerable<Pomodoro> openPomodoros = _context.Pomodoroes.Where(p => p.Username == pomodoro.Username && 
         (p.CompletedAt == null && p.ResetAt == null ));
     foreach (var openPomodoro in openPomodoros)
     {
         openPomodoro.ResetAt = DateTime.Now;
     }
         
     _context.Pomodoroes.Add(pomodoro);
 }
コード例 #2
0
        public string StartPomodoro(int activityId, string username)
        {
            Pomodoro pomodoro = new Pomodoro();
            pomodoro.ActivityId = activityId;
            pomodoro.Username = username;
            pomodoro.CreatedAt = DateTime.Now;

            _pomodoros.AddPomodoro(pomodoro);
            _pomodoros.Save();

            return "Pomodoro started.";
        }