internal List <TrainingDay> FindTrainingDay(TrainingDayCriteria trainingDayCriteria, TrainingDayScenario trainingDayScenario) { var trainingDays = _trainingDayModule.Find(trainingDayCriteria); if (trainingDayScenario != null && trainingDayScenario.ManageExercise && trainingDays != null) { foreach (var trainingDay in trainingDays) { CompleteTrainingDayWithExercise(trainingDay); } } return(trainingDays); }
internal List <TrainingDay> FindTrainingDay(TUnitType userUnit, TrainingDayCriteria trainingDayCriteria, TrainingDayScenario trainingDayScenario) { var trainingDays = _trainingDayModule.Find(userUnit, trainingDayCriteria); if (trainingDayScenario != null && trainingDayScenario.ManageExercise && trainingDays != null && trainingDays.Count > 0) { var criteriaList = new CriteriaList <TrainingExerciseCriteria>(); string userId = null; foreach (var trainingDay in trainingDays) { criteriaList.Add(CreateTrainingExerciseCriteria(trainingDay)); if (userId == null) { userId = trainingDay.UserId; } } var trainingExerciseList = _trainingExercisesService.FindTrainingExercise(criteriaList); if (trainingExerciseList != null) { foreach (var trainingDay in trainingDays) { foreach (var trainingExercise in trainingExerciseList) { if (trainingExercise != null && (trainingDay.UserId != null && trainingDay.UserId == trainingExercise.UserId) && (trainingDay.Year == trainingExercise.Year) && (trainingDay.WeekOfYear == trainingExercise.WeekOfYear) && (trainingDay.DayOfWeek == trainingExercise.DayOfWeek) && (trainingDay.TrainingDayId == trainingExercise.TrainingDayId)) { if (trainingDay.TrainingExercises == null) { trainingDay.TrainingExercises = new List <TrainingExercise>(); } trainingDay.TrainingExercises.Add(trainingExercise); } } } } } return(trainingDays); }