PM.BLL/PMService.cs
/// <summary>
/// Builds only the commands in an interval
/// </summary>
/// <param name="interval">The interval</param>
/// <param name="workoutDetails">The workout details</param>
/// <returns>Enumerable of the commands</returns>
Builds only the commands in an interval
Builds only the commands in an interval
private IEnumerable<ICommand>? BuildInterval(Interval interval, WorkoutDetails workoutDetails)
        {
            if (interval.WorkoutType == null && interval.IntervalType == null)
            {
                _logger.LogCritical("Workout type and Interval type was unexpectedly null. One must be specified based on Variable vs Fixed. No workout has been set.");
                return null;
            }
            if (interval.Duration == null)
            {
                _logger.LogCritical("Duration was unexpected null. No workout has been set.");
                return null;
            }
            int durationValue;
            int? splitValue = null;
            if (workoutDetails.WorkoutDuration == WorkoutDuration.Time)
            {
                durationValue = interval.Duration.Value * 100;
                if (workoutDetails.RequireSplits && interval.Splits != null)
                {
                    splitValue = interval.Splits.Value * 100;
                }
            }
            else
            {
                durationValue = interval.Duration.Value;
                if (workoutDetails.RequireSplits && interval.Splits != null)
                {
                    splitValue = interval.Splits.Value;
                }
            }
            if (splitValue == null && workoutDetails.RequireSplits)
            {
                _logger.LogCritical("Split Value was unexpectedly null. No workout has been set.");
                return null;
            }
            List<ICommand> commands = new();
            if (interval.WorkoutType != null)
            {
                commands.Add(new SetWorkoutTypeCommand(interval.WorkoutType.Value));
            }
            commands.Add(new SetWorkoutDurationCommand(workoutDetails.WorkoutDuration, durationValue));
            if (workoutDetails.RequireSplits && splitValue != null)
            {
                commands.Add(new SetSplitDurationCommand(workoutDetails.WorkoutDuration, splitValue.Value));
            }
            else if ((workoutDetails.RequireRest || interval.IntervalType != null) && interval.SecondsOfRest != null)
            {
                commands.Add(new SetRestDurationCommand(interval.SecondsOfRest.Value));
            }
            if (interval.TargetPace != null)
            {
                commands.Add(new SetTargetPaceCommand(interval.TargetPace.Value));
            }
            return commands;
        }
private IEnumerable < ICommand > ? BuildInterval ( Interval interval , WorkoutDetails workoutDetails ) { if ( interval . WorkoutType == null && interval . IntervalType == null ) { _logger . LogCritical ( " " ) ; return null ; } if ( interval . Duration == null ) { _logger . LogCritical ( " " ) ; return null ; } int durationValue ; int ? splitValue = null ; if ( workoutDetails . WorkoutDuration == WorkoutDuration . Time ) { durationValue = interval . Duration . Value * 100 ; if ( workoutDetails . RequireSplits && interval . Splits != null ) { splitValue = interval . Splits . Value * 100 ; } } else { durationValue = interval . Duration . Value ; if ( workoutDetails . RequireSplits && interval . Splits != null ) { splitValue = interval . Splits . Value ; } } if ( splitValue == null && workoutDetails . RequireSplits ) { _logger . LogCritical ( " " ) ; return null ; } List < ICommand > commands = new ( ) ; if ( interval . WorkoutType != null ) { commands . Add ( new SetWorkoutTypeCommand ( interval . WorkoutType . Value ) ) ; } commands . Add ( new SetWorkoutDurationCommand ( workoutDetails . WorkoutDuration , durationValue ) ) ; if ( workoutDetails . RequireSplits && splitValue != null ) { commands . Add ( new SetSplitDurationCommand ( workoutDetails . WorkoutDuration , splitValue . Value ) ) ; } else if ( ( workoutDetails . RequireRest || interval . IntervalType != null ) && interval . SecondsOfRest != null ) { commands . Add ( new SetRestDurationCommand ( interval . SecondsOfRest . Value ) ) ; } if ( interval . TargetPace != null ) { commands . Add ( new SetTargetPaceCommand ( interval . TargetPace . Value ) ) ; } return commands ; }
Builds only the commands in an interval
Builds only the commands in an interval
// Time is in 0.01s resolution, so requires converstion // Other durations are valid as-is
Enumerable of the commands
Enumerable of the commands
interval
Interval
None
workoutDetails
WorkoutDetails
The workout details
The workout details