Exemple #1
0
        private void SaveButtonTouchUpInside(object sender, EventArgs e)
        {
            _schedule.Period = (SchedulePeriod)(int)_schedulePicker.SelectedRowInComponent(0);
            var startHourTranslatedIndex = _startTimePicker.SelectedRowInComponent(0) == 11 ? 0 : _startTimePicker.SelectedRowInComponent(0) + 1;
            var startHour   = (int)(startHourTranslatedIndex + (12 * _startTimePicker.SelectedRowInComponent(2)));
            var startMinute = (int)_startTimePicker.SelectedRowInComponent(1) * 15;
            var startTime   = new DateTime(1, 1, 1, startHour, startMinute, 0);

            var endHourTranslatedIndex = _endTimePicker.SelectedRowInComponent(0) == 11 ? 0 : _endTimePicker.SelectedRowInComponent(0) + 1;
            var endHour   = (int)(endHourTranslatedIndex + (12 * _endTimePicker.SelectedRowInComponent(2)));
            var endMinute = (int)_endTimePicker.SelectedRowInComponent(1) * 15;
            var endTime   = new DateTime(1, 1, 1, endHour, endMinute, 0);

            if (startTime >= endTime)
            {
                GeneralAlertDialogs.ShowValidationErrorPopUp(this, "Please make sure your start time is before your end time.");
                return;
            }

            _schedule.StartTime = startTime;
            _schedule.EndTime   = endTime;

            Data.SaveExerciseSchedule(_schedule);

            ServiceManager.RestartNotificationServiceIfNeeded();
            NavigationController.PopViewController(true);
        }
        private void SaveButtonTouchUpInside(object sender, EventArgs e)
        {
            ShowHideCustomName();
            var exerciseType = (PreBuiltExersises)(int)_exerciseTypePicker.SelectedRowInComponent(0);

            if (exerciseType == PreBuiltExersises.Custom && string.IsNullOrWhiteSpace(CustomExerciseName.Text))
            {
                GeneralAlertDialogs.ShowValidationErrorPopUp(this, "Please enter a name for your exercise.");
                return;
            }

            if (_selectedExercise != null)
            {
                _selectedExercise.Name     = exerciseType == PreBuiltExersises.Custom ? CustomExerciseName.Text : string.Empty;
                _selectedExercise.Quantity = (int)_repetitionTypePicker.SelectedRowInComponent(0) + 1;
                _selectedExercise.Type     = exerciseType;
                Data.UpdateExerciseBlock(_selectedExercise);
            }
            else
            {
                Data.InsertExerciseBlock(new ExerciseBlock
                {
                    Name     = exerciseType == PreBuiltExersises.Custom ? CustomExerciseName.Text : string.Empty,
                    Quantity = (int)_repetitionTypePicker.SelectedRowInComponent(0) + 1,
                    Type     = exerciseType,
                    Enabled  = true
                });
            }

            ServiceManager.RestartNotificationServiceIfNeeded();
            NavigationController.PopViewController(true);
        }