Пример #1
0
        public ActionResult Search([Bind(Exclude = "Id")] CustomerModel data)
        {
            var model         = new CustomerSearchModel();
            var searchResults = CustomerInfo.GetByAny(data).Take(25);

            model.Fill(data);
            var results = searchResults.ToList();

            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }
            TempData[ResultMessage] = $"{model.Results.Count} matches found";

            return(View(CustomerSearchController.SearchView, model));
        }
Пример #2
0
        public ActionResult SearchResults(string id, string firstName, string lastName)
        {
            var model = new CustomerSearchModel()
            {
                Id = id.TryParseInt32(), Key = id.TryParseGuid(), FirstName = firstName, LastName = lastName
            };
            var searchResults = CustomerInfo.GetByAny(model).Take(25);

            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }
            TempData[ResultMessage] = $"{model.Results.Count} matches found";

            return(PartialView(CustomerSearchController.SearchResultsView, model.Results));
        }
Пример #3
0
        public ActionResult Search(CustomerSearchModel model)
        {
            IQueryable <CustomerInfo> searchResults;

            ModelState.Clear();
            searchResults = CustomerInfo.GetBySearchFields(model); // Find matches based on all fields
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults.ToList());
            }
            else
            {
                ModelState.AddModelError("Result", "0 matches found");
            }

            return(View(CustomerController.SearchView, model));
        }
Пример #4
0
        public ActionResult Search(CustomerSearchModel model)
        {
            IQueryable <CustomerInfo> searchResults;

            ModelState.Clear();
            searchResults = CustomerInfo.GetByAny(model).Take(25);
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults.ToList());
            }
            else
            {
                ModelState.AddModelError("Result", "0 matches found");
            }

            return(View(CustomerSearchController.SearchView, model));
        }
Пример #5
0
        public ActionResult SearchResults(string id, string firstName, string lastName)
        {
            Int32 idStrong            = id.TryParseInt32();
            CustomerSearchModel model = new CustomerSearchModel()
            {
                ID = idStrong, FirstName = firstName, LastName = lastName
            };
            IQueryable <CustomerInfo> searchResults;

            ModelState.Clear();
            searchResults = CustomerInfo.GetBySearchFields(model); // Find matches based on all fields
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults);
            }
            else
            {
                ModelState.AddModelError("Result", "0 matches found");
            }

            return(PartialView(CustomerController.SearchResultsView, model.Results)); // Return partial view for client-side to render
        }
        public ActionResult Search(CustomerModel data)
        {
            var model = new CustomerSearchModel();
            IQueryable <CustomerInfo> searchResults;

            model = data.CastOrFill <CustomerSearchModel>();
            using (var reader = new EntityReader <CustomerInfo>())
            {
                searchResults = reader.GetAll()
                                .Where(x => (model.FirstName != Defaults.String && x.FirstName.Contains(model.FirstName)) ||
                                       (model.LastName != Defaults.String && x.LastName.Contains(model.LastName)) ||
                                       (model.BirthDate != Defaults.Date && x.BirthDate == model.BirthDate) ||
                                       (x.Id == model.Id)).Take(25);
            }
            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }
            TempData[ResultMessage] = $"{model.Results.Count} matches found";

            return(View(CustomerSearchController.SearchView, model));
        }
        public ActionResult SearchResults(string id, string firstName, string lastName)
        {
            var model = new CustomerSearchModel()
            {
                Id = id.TryParseInt32(), Key = id.TryParseGuid(), FirstName = firstName, LastName = lastName
            };
            IQueryable <CustomerInfo> searchResults;

            using (var reader = new EntityReader <CustomerInfo>())
            {
                searchResults = reader.GetAll()
                                .Where(x => (model.FirstName != Defaults.String && x.FirstName.Contains(model.FirstName)) ||
                                       (model.LastName != Defaults.String && x.LastName.Contains(model.LastName)) ||
                                       (model.BirthDate != Defaults.Date && x.BirthDate == model.BirthDate) ||
                                       (x.Id == model.Id)).Take(25);
            }
            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }
            TempData[ResultMessage] = $"{model.Results.Count} matches found";

            return(PartialView(CustomerSearchController.SearchResultsView, model.Results));
        }