public void ShowAddTrainingGroup(IFormFactory formFactory, ITrainingGroupRepository trainingGroupRepository, ITrainingRepository trainingRepository, ITrainingPeriodRepository trainingPeriodRepository, IMainController mainController) { IAddTrainingGroupForm form = formFactory.CreateAddTrainingGroupForm(); List <Training> trainings = trainingRepository.GetAllTrainings(); List <TrainingPeriod> trainingPeriods = trainingPeriodRepository.GetAllTrainingPeriods().ToList(); // Uklanjanje zauzetih termina s popisa dostupnih termina foreach (TrainingGroup group in trainingGroupRepository.GetAllTrainingGroups()) { foreach (TrainingPeriod trainingPeriod in group.TrainingPeriods) { int index = trainingPeriods.FindIndex(period => period.PeriodId == trainingPeriod.PeriodId); if (index != -1) { trainingPeriods.RemoveAt(index); } } } List <TrainingPeriod> newPeriods = trainingPeriods.Select(item => item).ToList(); form.ShowModal(mainController, trainings, newPeriods); }