예제 #1
0
        private void StartTimer_Click(object sender, RoutedEventArgs e)
        {
            var selected = ActivityPicker.SelectedItem as Activity;

            if (selected is null)
            {
                return;
            }

            bindedActivity = selected;
            DataTransactionsService.HandleDataTransaction(new DataTransaction()
            {
                Action = DataTransaction.ActionType.Create,
                Data   = new TimeEntry()
                {
                    Activity  = bindedActivity,
                    StartTime = DateTime.Now
                }
            });

            startTime      = DateTime.Now;
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += TimerTick;
            timer.Start();
            UpdateList();
        }
예제 #2
0
        private void StopTimer_Click(object sender, RoutedEventArgs e)
        {
            var timeEntry = TimeEntriesService.GetStartedTimeEntry();

            if (timeEntry is null)
            {
                throw new Exception("Time entry already has end time.");
            }

            timeEntry.StopTime = DateTime.Now;

            DataTransactionsService.HandleDataTransaction(new DataTransaction()
            {
                Action = DataTransaction.ActionType.Edit,
                Data   = timeEntry
            });

            timer.Stop();
            UpdateList();
        }