コード例 #1
0
        private static SortDescriptor <CandidateElasticModel> Sort(CandidateSortModel sortModel)
        {
            var sort = new SortDescriptor <CandidateElasticModel>();

            if (sortModel == null)
            {
                return(sort.Descending(p => p.Id));
            }

            if (sortModel.LastContactDate != null)
            {
                sort = sortModel.LastContactDate == true
                    ? sort.Ascending(p => p.LastContactDate)
                    : sort.Descending(p => p.LastContactDate);
            }
            else if (sortModel.CreationDate != null)
            {
                sort = sortModel.CreationDate == true
                    ? sort.Ascending(p => p.Id)
                    : sort.Descending(p => p.Id);
            }
            else if (sortModel.RemindDate != null)
            {
                sort = sortModel.RemindDate == true
                    ? sort.Ascending(p => p.RemindDate)
                    : sort.Descending(p => p.RemindDate);
            }
            else
            {
                sort = sort.Descending(p => p.Id);
            }
            return(sort);
        }
コード例 #2
0
        public async Task <byte[]> AddToExcelCandidate(int skip, int amount,
                                                       CandidateSearchModel searchOptions, CandidateSortModel sortModel)
        {
            var candidates = await candidateService.Find(skip, amount, searchOptions, sortModel);

            var excelCandidateList = candidates.Select(ConvertToExcelModel).ToList();

            var result = ExcelCreator.GenerateExcel(excelCandidateList);

            return(result);
        }
コード例 #3
0
        public async Task <HttpContent> GetExcelByCandidates(int skip, int amount,
                                                             CandidateSearchModel searchModel, CandidateSortModel sortModel)
        {
            var stream = new MemoryStream(await AddToExcelCandidate(skip, amount, searchModel, sortModel));

            var content = CreateContent(stream, "Candidates.xlsx");

            return(content);
        }
コード例 #4
0
        public async Task <ICollection <Candidate> > Paging(int skip, int amount, CandidateSortModel sortModel = null)
        {
            var result = await Task.Run(() => candidateRepository.PagingDeafaultOrderByDecending(skip, amount, s => s.Id));

            return(result.ToList());
        }
コード例 #5
0
        public async Task <ICollection <Candidate> > Find(int skip, int amount, CandidateSearchModel searchOptions, CandidateSortModel sortModel)
        {
            IEnumerable <Candidate> candidates;

            if (searchOptions != null)
            {
                candidates = await Task.Run(() => candidateRepository.Find(searchOptions));
            }
            else
            {
                candidates = await Task.Run(() => candidateRepository.ReadAll());
            }

            candidates = Sorting(candidates, sortModel);

            var result = candidates.Skip(skip).Take(amount).ToList();

            return(result);
        }
コード例 #6
0
        private static IEnumerable <Candidate> Sorting(IEnumerable <Candidate> candidates, CandidateSortModel sortModel)
        {
            if (sortModel == null)
            {
                candidates = candidates.OrderByDescending(x => x.Id);
                return(candidates);
            }

            if (sortModel.CreationDate != null)
            {
                candidates = sortModel.RemindDate == true
                    ? candidates.OrderBy(x => x.Id)
                    : candidates.OrderByDescending(x => x.Id);
            }
            else if (sortModel.LastContactDate != null)
            {
                candidates = sortModel.RemindDate == true
                    ? candidates.OrderBy(x => x.LastContactDate)
                    : candidates.OrderByDescending(x => x.LastContactDate);
            }
            else if (sortModel.RemindDate != null)
            {
                candidates = sortModel.RemindDate == true
                    ? candidates.OrderBy(x => x.Reminder)
                    : candidates.OrderByDescending(x => x.Reminder);
            }
            else
            {
                candidates = candidates.OrderByDescending(x => x.Id);
            }

            return(candidates);
        }
コード例 #7
0
        public async Task <IEnumerable <CandidateElasticModel> > Find(int skip, int amount,
                                                                      CandidateSearchModel searchOptions, CandidateSortModel sortModel)
        {
            var result = await Task.Run(() => _candidateElasticRepository.Search(skip, amount, searchOptions, sortModel));

            return(result);
        }
コード例 #8
0
        public IEnumerable <CandidateElasticModel> Search(int skip, int amount,
                                                          CandidateSearchModel searchModel, CandidateSortModel sortModel)
        {
            var sort = Sort(sortModel);

            searchModel = searchModel ?? new CandidateSearchModel();
            return(_client.Search <CandidateElasticModel>(s =>
                                                          s.Index(IndexName)
                                                          .Skip(skip)
                                                          .Take(amount)
                                                          .Query(q =>
                                                                 q.Nested(ns => ns
                                                                          .Path(p => p.PrimarySkill)
                                                                          .Query(qr => qr
                                                                                 .Term(x => x.PrimarySkill.TechSkill, searchModel.PrimarySkill)
                                                                                 )) &&
                                                                 q.Nested(ns => ns
                                                                          .Path(p => p.PrimarySkill)
                                                                          .Query(qr => qr
                                                                                 .Term(x => x.PrimarySkill.Level, searchModel.Level)
                                                                                 )) &&
                                                                 q.Term(x => x.HRM, searchModel.HRM) &&
                                                                 q.Term(x => x.City, searchModel.City) &&
                                                                 q.Term(x => x.Status.Id, searchModel.Status) &&
                                                                 //q.Match(m => m
                                                                 //    .Field(x => x.Phone)
                                                                 //    .Query(searchModel.Phone)
                                                                 //    .Fuzziness(Fuzziness.Auto)
                                                                 //) &&
                                                                 q.Fuzzy(x => x
                                                                         .Field(z => z.LastNameEng)
                                                                         // .Boost(1)
                                                                         .Value(searchModel.LastNameEng)
                                                                         .Fuzziness(Fuzziness.Auto)
                                                                         ) &&
                                                                 q.Fuzzy(x => x
                                                                         .Field(z => z.Skype)
                                                                         .Value(searchModel.Skype)
                                                                         .Fuzziness(Fuzziness.Auto)
                                                                         ) &&
                                                                 q.Fuzzy(x => x
                                                                         .Field(z => z.Email)
                                                                         .Value(searchModel.Email)
                                                                         .Fuzziness(Fuzziness.Auto)
                                                                         ) &&
                                                                 q.Fuzzy(x => x
                                                                         .Field(z => z.Phone)
                                                                         .Value(searchModel.Phone)
                                                                         .Fuzziness(Fuzziness.Auto)
                                                                         )
                                                                 )
                                                          .Sort(p => p = sort)
                                                          ).Documents);
        }