Example #1
0
        private List <SectionViewModel> GetSections(int idOfCourse)
        {
            var sections     = _courseData.GetSections().Where(c => c.CourseId == idOfCourse);
            var themes       = _courseData.GetThemes().Where(t => t.Id == idOfCourse);
            var viewSections = new List <SectionViewModel>();

            foreach (var section in sections)
            {
                viewSections.Add(new SectionViewModel()
                {
                    Id            = section.Id,
                    Name          = section.Name,
                    ParentSection = null,
                });
            }

            foreach (var section in viewSections)
            {
                var themesForSection = themes.Where(t => t.SectionId == section.Id);
                foreach (var theme in themesForSection)
                {
                    section.ChildSections.Add(new SectionViewModel()
                    {
                        Id   = theme.Id,
                        Name = theme.Name
                    });
                }
            }

            return(viewSections);
        }