Esempio n. 1
0
        // GET api/Students
        public IEnumerable <StudentModel> GetStudents()
        {
            DbStudentsRepository studentRepository = this.allRepositories.GetStudentsRepository();
            var studentEntities = studentRepository.All();

            var studentModels =
                from studEntity in studentEntities
                select new StudentModel()
            {
                Id        = studEntity.Id,
                FirstName = studEntity.FirstName,
                LastName  = studEntity.LastName,
                Age       = studEntity.Age,
                Grade     = studEntity.Grade,
                SchoolId  = studEntity.School.Id
            };

            return(studentModels.ToList());
        }
Esempio n. 2
0
        // GET api/Students
        public IEnumerable <StudentModel> GetStudents(string subject, decimal value)
        {
            DbStudentsRepository studentRepository = this.allRepositories.GetStudentsRepository();

            var studentEntities = studentRepository.All().Where(s => s.Marks.Any(m => (m.Subject == subject && m.Value > value)));

            var studentModels =
                from studEntity in studentEntities
                select new StudentModel()
            {
                Id        = studEntity.Id,
                FirstName = studEntity.FirstName,
                LastName  = studEntity.LastName,
                Age       = studEntity.Age,
                Grade     = studEntity.Grade,
                SchoolId  = studEntity.School.Id
            };

            return(studentModels.ToList());
        }