Пример #1
0
        private void ProgramDetailAssignment()
        {
            var subProgramLevelIds = SubProgramLevels.Select(s => s.SubProgramLevelID).ToList();
            List <TrainerProgramDetails> trainerDetails = new List <TrainerProgramDetails>();

            if (subProgramLevelIds.Any())
            {
                trainerDetails = (from tpd in _pMTEntityContext.PMT_TrainerProgramDetails.Where(s => subProgramLevelIds.Contains(s.SubProgramLevelId))
                                  join td in _pMTEntityContext.PMT_TrainerDetails on tpd.TrainerId equals td.TrainerId
                                  where !td.IsDeleted
                                  select new TrainerProgramDetails()
                {
                    TrainerDetails = td, SubProgramLevelId = tpd.SubProgramLevelId
                }
                                  ).ToList();
            }

            foreach (var sp in SubPrograms)
            {
                var result = SubProgramLevels.Where(s => s.SubProgramId == sp.SubProgramId).Sum(p => Convert.ToDouble(p.TotalHours));
                sp.TotalTopicHours = result;

                //TODO :- Remove later for now it's fine
                var subProgramLevelIDs = SubProgramLevels.Where(s => s.SubProgramId == sp.SubProgramId).Select(p => p.SubProgramLevelID).Distinct();
                sp.TotalTrainerCount = subProgramLevelIDs.Count();

                sp.TotalProgramCount = SubProgramLevels.Count(s => s.SubProgramId == sp.SubProgramId);

                sp.TotalLanguageCount = CountLangauges(trainerDetails.Where(s => subProgramLevelIDs.Contains(s.SubProgramLevelId)).Select(s => s.TrainerDetails).ToList());
            }
        }
Пример #2
0
        public async Task OnGet(Guid id)
        {
            if (id != default(Guid))
            {
                GetProgramName(id);
                var subPrograms = await _pMTEntityContext.PMT_SubPrograms.Where(s => s.ProgramId == id && !s.IsDeleted).OrderBy(s => s.SubProgramName).ToListAsync();

                SubPrograms = subPrograms.OrderBy(s => s.SubProgramName).ToList();

                var subProgramIds    = SubPrograms.Select(s => s.SubProgramId);
                var subPrgoramLevels = _pMTEntityContext.PMT_SubProgramLevel.Where(s => subProgramIds.Contains(s.SubProgramId)).ToList();
                SubProgramLevels = subPrgoramLevels.OrderBy(s => s.SubProgramLevelName).ToList();

                var subPrgramLevelIds = SubProgramLevels.Select(s => s.SubProgramLevelID);
                TotalProgramCount = SubProgramLevels.Count();

                ProgramDetailAssignment();
            }
        }
Пример #3
0
        public void OnGet(string searchString)
        {
            var subPrograms = _pMTEntityContext.PMT_SubPrograms.Where(s => searchString.Contains(s.SubProgramName));

            if (subPrograms.Count() == 1)
            {
                SubPrograms = subPrograms;
                GetProgramName(SubPrograms.FirstOrDefault().ProgramId);
            }

            var subprogramID     = SubPrograms.Select(s => s.SubProgramId).ToList();
            var subLevelPrograms = _pMTEntityContext.PMT_SubProgramLevel.Where(s => subprogramID.Contains(s.SubProgramId));

            SubProgramLevels = subLevelPrograms;
            var subPrgramLevelIds = SubProgramLevels.Select(s => s.SubProgramLevelID);

            TotalProgramCount = SubProgramLevels.Count();

            ProgramDetailAssignment();
        }