예제 #1
0
        public async Task <IEnumerable <ModuleSummary> > GetModulesPerProgramLevel(ProgramLevelDto programLevelDto)
        {
            var moduleHasAcademicLevels = _unitOfWork.ModuleHasAcademicLevelRepository
                                          .Find(m => m.AcademicLevel == programLevelDto.Level).ToList();
            List <Module> modules = new List <Module>();

            foreach (var moduleHasAcademicLevel in moduleHasAcademicLevels)
            {
                var module =
                    await _unitOfWork.ModuleRepository.GetFullModule(moduleHasAcademicLevel.Module);

                var moduleHasProgram =
                    module.ModuleHasProgram
                    .SingleOrDefault(m => m.Program == programLevelDto.Program);

                // var byIdAsync =
                //     _unitOfWork.ModuleHasProgramRepository

                var r = 0;
                // var moduleHasProgram = moduleHasPrograms
                //     .SingleOrDefault(m => m.Program == programLevelDto.Program && m.Module == module.Id);
                //
                if (moduleHasProgram != null)
                {
                    modules.Add(module);
                }
            }

            var modulesPerProgramLevel =
                _mapper.Map <IEnumerable <Module>, IEnumerable <ModuleSummary> >(modules);

            return(modulesPerProgramLevel);
        }
예제 #2
0
        public async Task <IActionResult> GetModulesPerProgramLevel(int level, int program)
        {
            var programLevelDto = new ProgramLevelDto
            {
                Level   = level,
                Program = program
            };
            var modulesPerProgramLevel =
                await _schoolService.GetModulesPerProgramLevel(programLevelDto);

            return(Ok(modulesPerProgramLevel));
        }