Exemple #1
0
        private void LoadData()
        {
            using (var helper = new DbHelper.Subject())
            {
                var subClss      = helper.ListEarlierSubjectClasses(UserId);
                var againCurrent = subClss.Where(x => !(x.SessionComplete ?? false)).ToList();

                var againCurrentSubs = againCurrent.Where(x => x.IsRegular).Select(x => x.SubjectStructure.Subject).Distinct()
                                       .Select(x => x.Id).ToList();
                //var reg =
                var run = subClss.Where(x => x.IsRegular && (x.SessionComplete ?? false)).GroupBy(x => x.RunningClass).ToList();
                foreach (var r in run)
                {
                    var nodeuc =
                        (EarlierUc_NodesUc)Page.LoadControl("~/ViewsSite/User/ModulesUc/EarlierUc_NodesUc.ascx");
                    //key is used to display year/subyear
                    var subjects = r.Select(x => x.SubjectStructure.Subject)
                                   .Distinct()
                                   .Where(x => !againCurrentSubs.Contains(x.Id))
                                   .Distinct().OrderBy(x => x.FullName).ToList();
                    nodeuc.SetStructureData(r.Key.Year, r.Key.SubYear, subjects);
                    pnlRegularCourses.Controls.Add(nodeuc);
                }
                againCurrentSubs = againCurrent.Where(x => !x.IsRegular).Select(x => x.Subject).Distinct()
                                   .Select(x => x.Id).ToList();
                var irrRun = subClss.Where(x => !x.IsRegular && (x.SessionComplete ?? false))
                             .Select(x => x.Subject).Distinct().Where(x => !againCurrentSubs.Contains(x.Id))
                             .Distinct().OrderBy(x => x.FullName).ToList();

                if (irrRun.Any())
                {
                    divNonRegular.Visible = true;
                    dListNonRegularSubjects.DataSource = irrRun;
                    dListNonRegularSubjects.DataBind();
                }
                else
                {
                    if (!run.Any())
                    {
                        if (EmptyData != null)
                        {
                            EmptyData(this, new EventArgs());
                        }
                    }
                    divNonRegular.Visible = false;
                    dListNonRegularSubjects.DataSource = null;
                    dListNonRegularSubjects.DataBind();
                }
            }
        }