Exemple #1
0
        // ############################################################
        public IEnumerable <StudentBase> StudentSearch(StudentSearch newItem)
        {
            // var o = ds.Students.SingleOrDefault(a => a.name == newItem.searchTerm);
            var o = ds.Students.Where(a => a.name.Contains(newItem.searchTerm));

            if (o == null)
            {
                return(null);
            }
            else
            {
                IEnumerable <StudentBase> x = Mapper.Map <IEnumerable <StudentBase> >(o);
                return(x);
            }
        }
Exemple #2
0
        public ActionResult Search(int?id, StudentSearch newItem)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("search"));
            }

            var foundStudents = m.StudentSearch(newItem);

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


            return(View("SearchPost", foundStudents));
        }