コード例 #1
0
        private void SaveData()
        {
            _exerciseSchedule.Period = (SchedulePeriod)_reminderPeriodSpinner.SelectedItemPosition;
            _exerciseSchedule.Type   = (ScheduleType)_scheduleTypeSpinner.SelectedItemPosition;


            if (_selectedStartTime >= _selectedEndTime)
            {
                _userNotification.ShowValidationErrorPopUp(this, Resource.String.TimeRangeValidation);
                return;
            }

            _exerciseSchedule.StartTime = _selectedStartTime;
            _exerciseSchedule.EndTime   = _selectedEndTime;

            Data.SaveExerciseSchedule(_exerciseSchedule);
            _exerciseSchedule = Data.GetExerciseSchedule();
            _serviceManager.RestartNotificationServiceIfNeeded(this, _exerciseSchedule);
            Data.SetMovementLocationsEnabled(_movementLocationsEnabledCheckbox.Checked);

            Data.InsertAllMovementLocations(_updatedMovementLocations.Except(_initialMovementLocations));
            Data.DeleteAllMovementLocations(_initialMovementLocations.Except(_updatedMovementLocations).Select(ml => ml.Id));

            Finish();
        }
コード例 #2
0
        private void SaveData()
        {
            var exerciseType = (PreBuiltExersises)_exerciseTypeSpinner.SelectedItemPosition;

            if (exerciseType == PreBuiltExersises.Custom && string.IsNullOrWhiteSpace(_customExerciseNameText.Text))
            {
                _userNotification.ShowValidationErrorPopUp(this, Resource.String.ExerciseNameValidation);
                return;
            }

            if (string.IsNullOrWhiteSpace(_repetitionText.Text))
            {
                _userNotification.ShowValidationErrorPopUp(this, Resource.String.RepetitionsMissingValidation);
                return;
            }
            if (!int.TryParse(_repetitionText.Text, out int repetitions))
            {
                _userNotification.ShowValidationErrorPopUp(this, Resource.String.RepetitionWholeNumberValidation);
                return;
            }

            if (_currentExerciseId.HasValue)
            {
                var exercise = _exerciseBlocks.Single(e => e.Id == _currentExerciseId);

                exercise.Name     = exerciseType == PreBuiltExersises.Custom ? _customExerciseNameText.Text : string.Empty;
                exercise.Quantity = repetitions;
                exercise.Type     = exerciseType;
                Data.UpdateExerciseBlock(exercise);
            }
            else
            {
                Data.InsertExerciseBlock(new ExerciseBlock
                {
                    Name     = exerciseType == PreBuiltExersises.Custom ? _customExerciseNameText.Text : string.Empty,
                    Quantity = repetitions,
                    Type     = exerciseType,
                    Enabled  = true
                });
            }

            Finish();
        }