Exemple #1
0
        // GET: Search
        public ActionResult Search()
        {
            var form = new IncidentSearch();

            form.options.Add("All");
            form.options.Add("Description");
            form.options.Add("Student");
            form.options.Add("Instructor");
            form.options.Add("Course");
            return(View(form));
        }
Exemple #2
0
        public ActionResult Search(int?id, IncidentSearch newItem)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("search"));
            }

            var foundIncidents = m.IncidentSearch(newItem);

            if (foundIncidents == null || foundIncidents.Count() == 0)
            {
                return(RedirectToAction("search"));
            }


            return(View("SearchPost", foundIncidents));
        }
Exemple #3
0
        public IEnumerable <IncidentBase> IncidentSearch(IncidentSearch newItem)
        {
            var o = ds.Incidents.Where(a => a.description.Contains(newItem.searchTerm));
            var p = ds.Incidents.Where(a => a.Instructor.name.Contains(newItem.searchTerm));
            var q = ds.Students.Where(a => a.name.Contains(newItem.searchTerm));

            o = o.Concat(p);

            if (o == null)
            {
                return(null);
            }
            else
            {
                IEnumerable <IncidentBase> x = Mapper.Map <IEnumerable <IncidentBase> >(o);
                return(x);
            }
        }