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); }
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."; }