public async Task <bool> ChangeWorkoutOrders(PlannedWorkoutDateUpdate dateUpdate, int userId)
        {
            await Extensions.FindUser(userId, _userRepository, _cache);

            var existing = await _plannedWorkoutRepository.GetAll(dateUpdate.WorkoutOrders.Select(x => x.WorkoutId).ToList(), userId);

            if (existing.Count != dateUpdate.WorkoutOrders.Count)
            {
                throw new RestException(System.Net.HttpStatusCode.BadRequest, "Invalid workoutIds.");
            }

            var existingInTimeSpan = await _plannedWorkoutRepository.GetAllMatchingTimeSpan(DateTime.Parse(dateUpdate.ScheduledDate), dateUpdate.TimeOfDay, userId);

            if (existingInTimeSpan.Any(x => !existing.Contains(x)))
            {
                throw new RestException(System.Net.HttpStatusCode.BadRequest, "Does not contain all workouts in this time span.");
            }

            var toUpdate = existing.Select(x =>
            {
                x.UpdateDateValues(dateUpdate);
                return(x);
            }).ToList();

            return(await _plannedWorkoutRepository.UpdateMany(toUpdate) == toUpdate.Count);
        }