Esempio n. 1
0
        public Stream SearchStudents(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            var searchMethod = new StudentSearchMethod();

            if (!searchMethod.IsIndexExist())
            {
                searchMethod.AddToIndex(_studentRepository.Value.GetStudents());
            }

            var searchResult = searchMethod.Search(text);

            var data = new Dictionary <string, IEnumerable <Student> > {
                { "student", searchResult }
            };
            var result = new Dictionary <string, Dictionary <string, IEnumerable <Student> > > {
                { "data", data }
            };

            return(GetResultStream(result));
        }
Esempio n. 2
0
        public ActionResult Index(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(RedirectToAction("Index", "Lms"));
            }

            DateTime start = DateTime.Now;


            var model = new SearchViewModel();

            var ssm = new StudentSearchMethod();

            if (!ssm.IsIndexExist())
            {
                ssm.AddToIndex(_studentRepository.Value.GetStudents());
            }
            model.Students = ssm.Search(query);

            var gSearchMethod = new GroupSearchMethod();

            if (!gSearchMethod.IsIndexExist())
            {
                gSearchMethod.AddToIndex(_groupRepository.Value.GetGroups());
            }
            model.Groups = gSearchMethod.Search(query);

            var psm = new ProjectSearchMethod();

            if (!psm.IsIndexExist())
            {
                psm.AddToIndex(_projectRepository.Value.GetProjects());
            }
            model.Projects = psm.Search(query);

            var lsm = new LecturerSearchMethod();

            if (!lsm.IsIndexExist())
            {
                lsm.AddToIndex(_lecturerRepository.Value.GetLecturers());
            }
            model.Lecturers = lsm.Search(query);

            DateTime finish = DateTime.Now;
            TimeSpan delta  = finish - start;

            long ticks = delta.Ticks;

            return(View(model));
        }