Пример #1
0
        public async Task <IEnumerable <Vacancy> > GetAsync(VacancySearchFilter filter)
        {
            var builder = new VacancySearchBuilder(_context);
            var query   = builder.BuildQuery(filter);

            var request = IncludeReferences(query);

            var result = await request.ToListAsync();

            await LoadReferences();

            return(result);
        }
Пример #2
0
        public async Task <IActionResult> Search([FromBody] VacancySearchFilter filter)
        {
            var builder = new VacancySearchBuilder(_context);
            var query   = builder.BuildQuery(filter);

            var includableQuery = query
                                  .Include(x => x.Address)
                                  //.AlsoInclude(x => x.Area)
                                  .ThenInclude(x => x.Station)
                                  .ThenInclude(x => x.Line)
                                  .ThenInclude(x => x.Metro)
                                  .Include(x => x.Department)
                                  .Include(x => x.DrivingLicenseTypes)
                                  .ThenInclude(x => x.DrivingLicenseType)
                                  .Include(x => x.Employer)
                                  .Include(x => x.Employment)
                                  //.Include(x => x.Industry)
                                  .Include(x => x.KeySkills)
                                  .ThenInclude(x => x.Skill)
                                  .Include(x => x.Languages)
                                  //.AlsoInclude(x => x.Language)
                                  //.AlsoInclude(x => x.Level)
                                  .Include(x => x.Specializations)
                                  //.ThenInclude(x => x.Specialization)
                                  .Include(x => x.Salary)
                                  .ThenInclude(x => x.Currency)
                                  .Include(x => x.Schedule)
                                  .Include(x => x.Tests)
                                  .Include(x => x.VacancyStatus)
                                  .Skip(filter.Offset)
                                  .Take(filter.Count);

            await _context.Areas.LoadAsync();

            await _context.Languages.LoadAsync();

            await _context.LanguageLevels.LoadAsync();

            await _context.Specializations.LoadAsync();

            await _context.Industries.LoadAsync();

            var result = await includableQuery.ToListAsync();

            var dto = result.Select(Mapper.Map <DtoVacancy>).ToList();

            return(Ok(dto));
        }