Пример #1
0
        public HttpResponseMessage GetWithService(HttpRequestMessage request, string question = "*", string answer = "*", int serviceid = 0,
                                                  int procedureid = 0, int pagesize = 15, int pageindex = 1)
        {
            Expression <Func <tbFAQ, bool> > questionfilter, answerfilter, serviceidfilter, procedureidfilter = null;

            if (question != "*")
            {
                FuzzySearch _fuzz = new FuzzySearch(question);
                questionfilter = l => _fuzz.IsMatch(l.Question);
            }
            else
            {
                questionfilter = l => l.IsDeleted != true;
            }
            if (answer != "*")
            {
                FuzzySearch _fuzz = new FuzzySearch(answer);
                answerfilter = l => _fuzz.IsMatch(l.Answer);
                //answerfilter = l => l.ManagedbyId == managedbyid;
            }
            else
            {
                answerfilter = l => l.IsDeleted != true;
            }
            if (serviceid != 0)
            {
                serviceidfilter = l => l.ServiceId == serviceid;
            }
            else
            {
                serviceidfilter = l => l.IsDeleted != true;
            }
            if (procedureid != 0)
            {
                procedureidfilter = l => l.ProcedureId == procedureid;
            }
            else
            {
                procedureidfilter = l => l.IsDeleted != true;
            }
            var skipindex = pagesize * (pageindex - 1);
            var obj       = new FAQViewModel
            {
                FAQs = repo.GetWithoutTracking().Where(questionfilter).Where(answerfilter).Where(serviceidfilter).Where(procedureidfilter)
                       .OrderByDescending(a => a.Question).Skip(skipindex).Take(pagesize).ToList(),
                Procedure = procedureRepo.GetWithoutTracking().Where(a => a.ID == procedureid).FirstOrDefault(),
                Service   = serviceRepo.GetWithoutTracking().Where(a => a.ID == serviceid).FirstOrDefault()
            };

            HttpResponseMessage response = request.CreateResponse <FAQViewModel>(HttpStatusCode.OK, obj);

            return(response);
        }
        private ObservableCollection <string> ExecuteSearch(string searchText)
        {
            //string[] filters = searchText.Split(new[] { ' ' });
            //var q = from x in list
            //where filters.All(f => x.Contains(f))
            //select x;

            FuzzySearch _fuzz = new FuzzySearch(searchText);

            var q = from x in list
                    where _fuzz.IsMatch(x)
                    select x;


            //var q = from s in list where s.ToLower().Contains(searchText.ToLower()) select s;
            var results = new ObservableCollection <string>(q);

            return(results);
        }