Beispiel #1
0
        public List <Student> Search(StudentSearchCriteria criteria)
        {
            var students = session.QueryOver <Student>();

            if (!String.IsNullOrEmpty(criteria.PartialName))
            {
                string      pn          = String.Format("%{0}%", criteria.PartialName.Substring(0, Math.Min(50, criteria.PartialName.Length)));
                Disjunction disjunction = new Disjunction();

                disjunction.Add(Restrictions.On <Student>(e => e.FirstName).IsLike(pn));
                disjunction.Add(Restrictions.On <Student>(e => e.LastName).IsLike(pn));

                students = students.Where(disjunction);
            }

            if (criteria.Id.HasValue)
            {
                students = students.Where(x => x.Id == criteria.Id);
            }

            if (criteria.MathGeniusId.HasValue)
            {
                students = students.Where(x => x.MathGeniusId == criteria.MathGeniusId);
            }

            if (criteria.GraduationYear.HasValue)
            {
                students = students.Where(x => x.GraduationYear == criteria.GraduationYear);
            }

            return(students.List <Student>().ToList());
        }
        public void UpdateStudent()
        {
            //svc.InitializeData();
            ResetUnitOfWork();

            StudentSearchCriteria searchCriteria = new StudentSearchCriteria();

            searchCriteria.PartialName = "Gor";
            var     students       = svc.SearchStudents(searchCriteria);
            Student student        = students.OrderBy(x => x.FirstName).First();
            int     studentId      = student.Id;
            string  firstName      = "Ben";
            string  lastName       = "Dover";
            string  gender         = "F";
            int     graduationYear = 2013;

            svc.UpdateStudent(studentId, firstName, lastName, gender, graduationYear);

            ResetUnitOfWork();
            searchCriteria.PartialName = null;
            searchCriteria.Id          = studentId;
            students = svc.SearchStudents(searchCriteria);
            student  = students.OrderBy(x => x.FirstName).First();

            Assert.IsTrue(student.FirstName == firstName);
            Assert.IsTrue(student.LastName == lastName);
            Assert.IsTrue(student.Gender == gender);
            Assert.IsTrue(student.GraduationYear == graduationYear);
        }
Beispiel #3
0
        public List <Student> SearchStudentsTest(
            [PexAssumeUnderTest] StudentService target,
            StudentSearchCriteria criteria
            )
        {
            List <Student> result = target.SearchStudents(criteria);

            return(result);
            // TODO: add assertions to method StudentServiceTest.SearchStudentsTest(StudentService, StudentSearchCriteria)
        }
Beispiel #4
0
        //Search Option
        public List <Student> GetBookBySearch(StudentSearchCriteria model)
        {
            IEnumerable <Student> students = db.Students.Where(b => b.isDelete == false).AsQueryable();

            if (!string.IsNullOrEmpty(model.FirstName))
            {
                students = students.Where(b => b.FirstName.ToString().ToLower().Contains(model.FirstName.ToString().ToLower()));
            }
            return(students.ToList());
        }
Beispiel #5
0
        //
        // GET: /Book/
        public ActionResult Index(StudentSearchCriteria model)
        {
            var students = _studentManager.GetAllStudent();

            if (students == null)
            {
                students = new List <Student>();
            }
            model.GenderListItem     = GetGenderList();
            model.DepartmentListItem = GetDepartmentlist();
            model.Students           = students;
            return(View(model));
        }
 public List <Student> SearchStudent(StudentSearchCriteria criteria)
 {
     return(_data.Where(s =>
                        (string.IsNullOrEmpty(criteria.SearchText) ||
                         s.StudentID.ToString().Contains(criteria.SearchText) ||
                         s.FirstName.Contains(criteria.SearchText) ||
                         s.LastName.Contains(criteria.SearchText) ||
                         s.Address.Contains(criteria.SearchText) ||
                         s.Email.Contains(criteria.SearchText))
                        &&
                        (string.IsNullOrEmpty(criteria.ClassName) ||
                         s.Class.Contains(criteria.ClassName)
                        )
                        ).ToList());
 }
 public List <Student> GetBookBySearch(StudentSearchCriteria model)
 {
     return(_studentRepository.GetBookBySearch(model));
 }
 /// <summary>
 /// This method populates a StudentSearchCriteria object with values from the Criteria Controller
 /// </summary>
 /// <param name="criteriaController"></param>
 /// <returns></returns>
 private StudentSearchCriteria GetStudentCriteriaFromController(CriteriaController criteriaController)
 {
     var studentSearchCriteria = new StudentSearchCriteria();
     var studentName = criteriaController.ParseCriteria<Text.ValueObject>("StudentName").FirstOrDefault();
     studentSearchCriteria.StudentName = studentName == null ? string.Empty : studentName.Text;
     var studentId = criteriaController.ParseCriteria<Text.ValueObject>("StudentID").FirstOrDefault();
     studentSearchCriteria.StudentID = studentId == null ? string.Empty : studentId.Text;
     var inactiveRti =
         criteriaController.ParseCriteria<CheckBoxList.ValueObject>("RTI").Find(x => x.Text == RtiFormerYear);
     studentSearchCriteria.InactiveRTI = inactiveRti == null ? string.Empty : inactiveRti.Text;
     var tier1Rti = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("RTI")
         .Find(x => x.Text == RtiTier1);
     studentSearchCriteria.Tier1RTI = tier1Rti == null ? string.Empty : tier1Rti.Text;
     var tier2Rti = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("RTI")
         .Find(x => x.Text == RtiTier2);
     studentSearchCriteria.Tier2RTI = tier2Rti == null ? string.Empty : tier2Rti.Text;
     var tier3Rti = criteriaController.ParseCriteria<CheckBoxList.ValueObject>("RTI")
         .Find(x => x.Text == RtiTier3);
     studentSearchCriteria.Tier3RTI = tier3Rti == null ? string.Empty : tier3Rti.Text;
     studentSearchCriteria.Cluster = string.Join(",",
         criteriaController.ParseCriteria<CheckBoxList.ValueObject>("Cluster").Select(x => x.Text).ToList());
     studentSearchCriteria.SchoolTypes = string.Join(",",
         criteriaController.ParseCriteria<CheckBoxList.ValueObject>("SchoolType").Select(x => x.Text).ToList());
     studentSearchCriteria.School =
         Convert.ToInt32(criteriaController.ParseCriteria<DropDownList.ValueObject>("School")
             .Select(x => x.Value)
             .ToList()
             .FirstOrDefault());
     studentSearchCriteria.Grades = string.Join(",",
         criteriaController.ParseCriteria<CheckBoxList.ValueObject>("Grade").Select(x => x.Text).ToList());
     var demo1 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "1");
     studentSearchCriteria.Demo1 = demo1 == null ? string.Empty : demo1.DemoValue;
     var demo2 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "2");
     studentSearchCriteria.Demo2 = demo2 == null ? string.Empty : demo2.DemoValue;
     var demo3 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "3");
     studentSearchCriteria.Demo3 = demo3 == null ? string.Empty : demo3.DemoValue;
     var demo4 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "4");
     studentSearchCriteria.Demo4 = demo4 == null ? string.Empty : demo4.DemoValue;
     var demo5 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "5");
     studentSearchCriteria.Demo5 = demo5 == null ? string.Empty : demo5.DemoValue;
     var demo6 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "6");
     studentSearchCriteria.Demo6 = demo6 == null ? string.Empty : demo6.DemoValue;
     var demo7 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "7");
     studentSearchCriteria.Demo7 = demo7 == null ? string.Empty : demo7.DemoValue;
     var demo8 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "8");
     studentSearchCriteria.Demo8 = demo8 == null ? string.Empty : demo8.DemoValue;
     var demo9 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "9");
     studentSearchCriteria.Demo9 = demo9 == null ? string.Empty : demo9.DemoValue;
     var demo10 = criteriaController.ParseCriteria<Demographics.ValueObject>("Demographics").Find(x => x.DemoField == "10");
     studentSearchCriteria.Demo10 = demo10 == null ? string.Empty : demo10.DemoValue;
     studentSearchCriteria.ClassID = Convert.ToInt32(criteriaController.ParseCriteria<DropDownList.ValueObject>("Class").Select(x => x.Value).ToList().FirstOrDefault());
     return studentSearchCriteria;
 }
        /// <summary>
        /// This method loads all students the the current user has visibility too AND that are not already 
        /// enrolled in the current group.
        /// </summary>
        /// <returns>A list of students who are eligable to be added to this group</returns>
        public IEnumerable<GroupStudentDataContract> LoadStudentsAvailableForGroup()
        {
            var availableStudents = new List<GroupStudentDataContract>();
            var studentSearchCriteria = new StudentSearchCriteria();
            var criteriaController = GetCriteriaControllerFromMasterPage();

            if (criteriaController != null)
            {
                studentSearchCriteria = GetStudentCriteriaFromController(criteriaController);
            }

            switch (SessionObject.CurrentPortal)
            {
                case EntityTypes.District:
                    availableStudents = _groupProxy.GetStudentsByDistrictAvailableForGroup(GroupId,
                        SessionObject.LoggedInUser.Page, studentSearchCriteria,
                        DistrictParms.LoadDistrictParms().ClientID);
                    break;
                case EntityTypes.School:
                    if (studentSearchCriteria.School == 0)
                    {
                        studentSearchCriteria.School = SessionObject.LoggedInUser.School;
                    }

                    availableStudents = _groupProxy.GetStudentsBySchoolAvailableForGroup(GroupId,
                        SessionObject.LoggedInUser.Page, studentSearchCriteria, DistrictParms.LoadDistrictParms().ClientID);
                    break;
                case EntityTypes.Teacher:
                    availableStudents = _groupProxy.GetStudentsByTeacherAvailableForGroup(GroupId,
                        SessionObject.LoggedInUser.Page, studentSearchCriteria,
                        DistrictParms.LoadDistrictParms().ClientID);
                    break;
            }

            return availableStudents;
        }
Beispiel #10
0
 public List <Student> SearchStudents(StudentSearchCriteria criteria)
 {
     return(studentRepo.Search(criteria).ToList());
 }