コード例 #1
0
        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));
        }
コード例 #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));
        }
コード例 #3
0
        /// <summary>
        /// Implements the execution of <see cref="Search" />
        /// </summary>
        private void Search_Execute()
        {
            var presidents = PresidentRepository.GetAllPresidents();

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

            //force the IQueryable execution plan to execute
            var peopleResults = presidents.ToList();

            Application.Current.Dispatcher.Invoke(() => {
                SearchResults.Clear();

                foreach (var person in peopleResults.OrderBy(p => p.LastName))
                {
                    SearchResults.Add(person);
                }
            });
        }
コード例 #4
0
 public BLLPresident()
 {
     this._repository = new PresidentRepository();
 }