public async Task <IProgramResponse> GetBatchsDetailAsync(int profileId, int batchId)
        {
            try
            {
                var programs = await _appDbContext.Programmes.Include(m => m.ProgrammeTypeItem).Include(k => k.Batches).ToListAsync();

                var programViews = _mapper.Map <List <ProgramView> >(programs);

                var applications = _mapper.Map <List <ApplicationView> >(await _appDbContext.Applications
                                                                         .Include(k => k.StatusItem).Include(k => k.ReviewStatusItem).Include(k => k.AssessmentItem)
                                                                         .Include(k => k.SecurityItem).Include(k => k.VideoAssessmentStatus)
                                                                         .Where(k => k.ProfileId == profileId).ToListAsync());

                programViews.ForEach(k => k.Applications = applications);


                var programView = programViews.FirstOrDefault(k => k.BatchId == batchId);
                if (programView != null)
                {
                    programView.CompletedUsersList =
                        await GetProgramCompletedUserDetailsAsync(profileId, programView.BatchId ?? 0);
                }

                var profileCompleted = await _applicationProgressService.GetProgramCompletedDetailsAsync(profileId, batchId);

                profileCompleted.Program = programView;

                return(new ProgramResponse(profileCompleted));
            }
            catch (Exception e)
            {
                return(new ProgramResponse(e.Message, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IProgramResponse> GetBatchsDetailAsync(int profileId, int batchId)
        {
            try
            {
                var programs = await _appDbContext.Programmes.Include(m => m.ProgrammeTypeItem).Include(k => k.Batches).ToListAsync();

                var programViews      = _mapper.Map <List <ProgramView> >(programs);
                var programBatchViews = new List <ProgramView>();

                foreach (var item in programViews)
                {
                    var batchList = item.Batches.ToList();
                    foreach (var item2 in batchList)
                    {
                        // Type myTypeB = typeof(ProgramView);
                        //PropertyInfo fieldInfo = ProgramView..GetProperty("BatchView");


                        ProgramView progView = new ProgramView()
                        {
                            Id                    = item.Id,
                            TitleEn               = item.TitleEn,
                            TitleAr               = item.TitleAr,
                            DescriptionEn         = item.DescriptionEn,
                            DescriptionAr         = item.DescriptionAr,
                            Order                 = item.Order,
                            Fees                  = item.Fees,
                            Duration              = item.Duration,
                            IsHidden              = item.IsHidden,
                            ShortTitleEn          = item.ShortTitleEn,
                            ShortTitleAr          = item.ShortTitleAr,
                            ProgrammeTypeItemId   = item.ProgrammeTypeItemId,
                            ImageId               = item.ImageId,
                            DescriptionHtmlEn     = item.DescriptionHtmlEn,
                            DescriptionHtmlAr     = item.DescriptionHtmlAr,
                            SubDescriptionHtmlEn  = item.SubDescriptionHtmlEn,
                            SubDescriptionHtmlAr  = item.SubDescriptionHtmlAr,
                            ProgrammeTypeItem     = item.ProgrammeTypeItem,
                            isReminderSet         = item.isReminderSet,
                            Batches               = item.Batches,
                            Applications          = item.Applications,
                            Application_reference = item.Application_reference,
                            CompletedUsersList    = item.CompletedUsersList,
                            BatchView             = item2
                        };

                        programBatchViews.Add(progView);
                    }
                }
                var applications = _mapper.Map <List <ApplicationView> >(await _appDbContext.Applications
                                                                         .Include(k => k.StatusItem).Include(k => k.ReviewStatusItem).Include(k => k.AssessmentItem)
                                                                         .Include(k => k.SecurityItem).Include(k => k.VideoAssessmentStatus)
                                                                         .Where(k => k.ProfileId == profileId).ToListAsync());

                programBatchViews.ForEach(k => k.Applications = applications);


                var programView = programBatchViews.FirstOrDefault(k => k.BatchId == batchId);
                if (programView != null)
                {
                    programView.CompletedUsersList =
                        await GetProgramCompletedUserDetailsAsync(profileId, programView.BatchId ?? 0);
                }

                var profileCompleted = await _applicationProgressService.GetProgramCompletedDetailsAsync(profileId, batchId);

                profileCompleted.Program = programView;

                var isProgramOpen = await _appDbContext.Batches.Where(k => k.Id == batchId && !k.IsClosed && k.DateRegFrom <= DateTime.Now.Date && k.DateRegTo >= DateTime.Now.Date).FirstOrDefaultAsync();

                profileCompleted.isProgramOpen = isProgramOpen != null ? true : false;

                return(new ProgramResponse(profileCompleted));
            }
            catch (Exception e)
            {
                return(new ProgramResponse(e.Message, HttpStatusCode.InternalServerError));
            }
        }