public IHttpActionResult Get(String firstName       = "",
                                     String lastName        = "",
                                     String presidentNumber = "",
                                     DateTime?startDate     = null,
                                     DateTime?endDate       = null,
                                     String termCount       = "",
                                     Boolean?IsAlive        = null,
                                     String searchOperator  = "ANY")
        {
            var searchModel = new SearchModel
            {
                FirstName       = firstName,
                LastName        = lastName,
                PresidentNumber = presidentNumber,
                StartDate       = startDate,
                EndDate         = endDate,
                TermCount       = termCount,
                Alive           = IsAlive,
                SearchOperator  = searchOperator
            };

            var presidents = PresidentRepository.GetAllPresidents();

            if (searchModel.HasCriteria())
            {
                presidents = presidents.Where(searchModel.ToExpression());
            }

            return(Ok(presidents));
        }
Beispiel #2
0
        public ActionResult Index(SearchModel search)
        {
            var presidents = PresidentRepository.GetAllPresidents();

            if (search.HasCriteria())
            {
                presidents = presidents.Where(search.ToExpression());
            }
            search.SearchResults = presidents;

            return(View(search));
        }