Esempio n. 1
0
        public void LoadDTO()
        {
            ICollection <Student> students = svc.GetStudents();
            List <StudentDTO>     dto      = StudentDTO.StudentsToDTO(students.ToList());

            Assert.IsTrue(dto.Any());
        }
        // GET: odata/Student
        public IHttpActionResult GetStudent(ODataQueryOptions <Student> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);

                string            filter      = queryOptions.RawValues.Filter;
                int               skip        = 0;
                int               top         = 10;
                string            orderby     = queryOptions.OrderBy.RawValue;
                int               count       = 0;
                List <StudentDTO> studentList = StudentDTO.StudentsToDTO(studentService.GetStudents(filter, skip, top, orderby, out count));
                return(Ok <IEnumerable <StudentDTO> >(studentList));
            }
            catch (ODataException ex)
            {
                return(BadRequest(ex.Message));
            }
        }