private void ShowCreateExerciseDialog()
        {
            var dialogViewModel = new CreateExerciseViewModel();

            bool?success = dialogService.ShowDialog <CreateExerciseView>(this, dialogViewModel);

            DateTime today = DateTime.Today;

            if (success == true)
            {
                if (dialogViewModel.ItemToAdd.IsDailyRecurrence)
                {
                    dialogViewModel.ItemToAdd.DueTime = today;
                }
                else if (dialogViewModel.ItemToAdd.IsWeeklyRecurrence)
                {
                    // The (... + 7) % 7 ensures we end up with a value in the range [0, 6]
                    int requiredDueDay = ((int)dialogViewModel.ItemToAdd.WeeklyRecurrenceDay - (int)today.DayOfWeek + 7) % 7;
                    dialogViewModel.ItemToAdd.DueTime = today.AddDays(requiredDueDay);
                }
                else if (dialogViewModel.ItemToAdd.IsMonthlyRecurrence)
                {
                    int requiredDueMonth = ((int)dialogViewModel.ItemToAdd.MonthlyRecurrenceDay - (int)today.Month + DateTime.DaysInMonth(today.Year, today.Month)) % DateTime.DaysInMonth(today.Year, today.Month);
                    dialogViewModel.ItemToAdd.DueTime = today.AddDays(requiredDueMonth + 1); //dont ask me why i need a plus 1. I dont know
                }

                AllExerciseItems.Add(dialogViewModel.ItemToAdd);
                dataStore.AddExercise(dialogViewModel.ItemToAdd);

                SaveExerciseList();

                if (dialogViewModel.ItemToAdd.IsUsedInRoster)
                {
                    dialogViewModel.ItemToAdd.MarkExerciseCompletedChanged += OnMarkExerciseCompletedChanged; //check that you dont need to explicitly unsub when this item is removed
                    dialogViewModel.ItemToAdd.EditExericse   += OnEditExercise;
                    dialogViewModel.ItemToAdd.DeleteExercise += OnDeleteExercise;
                    ExerciseItemsToDo.Add(dialogViewModel.ItemToAdd);
                    OnUpdateTimerTick(null, null);
                }
            }
            RebuildList();
        }
        private void OnEditExercise(object sender, EventArgs e)
        {
            ExerciseItem itemToEdit = sender as ExerciseItem;

            //This is a somewhat custom version of the create exercise window
            var dialogViewModel = new CreateExerciseViewModel();

            dialogViewModel.ItemToAdd = itemToEdit;
            bool?success = dialogService.ShowDialog <CreateExerciseView>(this, dialogViewModel);

            if (success == true)
            {
                dataStore.UpdateExercise(dialogViewModel.ItemToAdd);

                if (dialogViewModel.ItemToAdd.IsUsedInRoster)
                {
                    //OnUpdateTimerTick(null, null);
                    RebuildList(); //have to rebuild list so that it updates the views
                }
            }
        }