/// <summary>
        ///
        /// </summary>
        /// <param name="subjectResourceParameters"></param>
        /// <returns></returns>
        public PagedList <Subject> GetSubjects(SubjectResourceParameters subjectResourceParameters)
        {
            if (subjectResourceParameters == null)
            {
                throw new ArgumentNullException(nameof(subjectResourceParameters));
            }

            //if (string.IsNullOrWhiteSpace(subjectResourceParameters.FirstName) && string.IsNullOrWhiteSpace(subjectResourceParameters.LastName))
            //{
            //    return GetSubjects();
            //}

            var collection = _context.Subjects as IQueryable <Subject>;

            if (!string.IsNullOrWhiteSpace(subjectResourceParameters.FirstName))
            {
                var firstName = subjectResourceParameters.FirstName.Trim();
                collection = collection.Where(a => a.FirstName == firstName);
            }

            if (!string.IsNullOrWhiteSpace(subjectResourceParameters.LastName))
            {
                var lastName = subjectResourceParameters.LastName.Trim();
                collection = collection.Where(a => a.LastName == lastName);
            }



            return(PagedList <Subject> .Create(collection, subjectResourceParameters.PageNumber, subjectResourceParameters.PageSize));
        }
Ejemplo n.º 2
0
        public ActionResult <IEnumerable <SubjectDto> > GetSubjects([FromQuery] SubjectResourceParameters subjectResourceParameters)
        {
            var subjectsFromRepo = _subjectOrderRepository.GetSubjects(subjectResourceParameters);

            List <SubjectDto> subjectsToReturn = new List <SubjectDto>();

            foreach (Subject subject in subjectsFromRepo)
            {
                subjectsToReturn.Add(new SubjectDto
                {
                    subjectId   = subject.SubjectId,
                    firstName   = subject.FirstName,
                    lastName    = subject.LastName,
                    dateOfBirth = subject.DateOfBirth,
                    titleId     = subject.TitleId
                });
            }

            return(Ok(subjectsToReturn));
        }
Ejemplo n.º 3
0
 public PagedList <Subject> GetSubjects(SubjectResourceParameters subjectResourceParameters)
 {
     //return _subjects;
     throw new NotImplementedException();
 }