Example #1
0
        private static void BuildDb()
        {
            var context = LessonDbContext.GetInstance();

            // Create the database if it does not exist
            context.Database.EnsureCreated();
        }
Example #2
0
        public IActionResult DeepSearch(string search)
        {
            var _search = search.ToLower();


            if (allTableJoin.Count < 1 || allTableJoin == null)
            {
                using (LessonDbContext context = new LessonDbContext())
                {
                    allTableJoin = (from l in context.Lessons
                                    join s in context.Subjects
                                    on l.id equals s.Lessonid
                                    join c in context.Contents
                                    on s.id equals c.Subjectid
                                    join w in context.ViewLevels
                                    on c.id equals w.Contentid
                                    where c.Tombstone == null
                                    select new CompositViewModel
                    {
                        LessonName = l.LessonName.ToLower(),
                        SubjectName = s.SubjectName.ToLower(),
                        ContentName = c.ContentName.ToLower(),
                        ViewLevelName = w.LevelContent.ToLower()
                    }).ToList();
                }
            }

            List <CompositViewModel> searchResult = new List <CompositViewModel>();

            if (allTableJoin != null)
            {
                allTableJoin.ForEach(c =>
                {
                    if (c.LessonName.Contains(_search) || c.SubjectName.Contains(_search) ||
                        c.ContentName.Contains(_search) || c.ViewLevelName.Contains(_search))
                    {
                        searchResult.Add(c);
                    }
                });
            }


            return(View("DeepSearch", searchResult));
        }
Example #3
0
        public IActionResult Index()
        {
            ListViewModel model = new ListViewModel();

            using (LessonDbContext context = new LessonDbContext())
            {
                model.CommandIndices = (from c in context.CommandIndices
                                        join l in context.Lessons
                                        on c.Lessonid equals l.id
                                        select new CommandIndexView {
                    id = c.id,
                    Command = c.Command,
                    Description = c.Description,
                    LessonName = l.LessonName
                }).ToList();
            }

            model.Lessons = _lesson.Table().ToList();
            return(View(model));
        }