Esempio n. 1
0
        private Vacancy GetOlderVersionSameVacancy(HeadHunterVacancy headHunterVacancy,
                                                   HeadHunterSnippet headHunterSnippet)
        {
            var vacancy = GetVacancy(headHunterVacancy, headHunterSnippet);

            vacancy.SourceUpdatedDate = vacancy.SourceUpdatedDate.AddDays(-1);
            return(vacancy);
        }
Esempio n. 2
0
        private async Task <Area> GetOrCreateAreaAsync(SourceType sourceType, HeadHunterVacancy headHunterVacancy)
        {
            var sourceArea =
                await _storageBroker.SelectSourceAreaByIdAndTypeIdAsync(sourceType.Id, headHunterVacancy.Area.Id) ??
                await AddSourceAreaAsync(sourceType, headHunterVacancy.Area);

            return(sourceArea.Area);
        }
Esempio n. 3
0
        private Employment GetEmployment(HeadHunterVacancy headHunterVacancyResponse)
        {
            var returnedEmployment = new Employment
            {
                Id = 1, Code = headHunterVacancyResponse.Employment.Id, Name = headHunterVacancyResponse.Employment.Name
            };

            return(returnedEmployment);
        }
Esempio n. 4
0
        private Vacancy GetVacancy(HeadHunterVacancy headHunterVacancy,
                                   HeadHunterSnippet headHunterSnippet)
        {
            var vacancy = GetRandomVacancy();

            vacancy.SourceId          = headHunterVacancy.Id;
            vacancy.SourceUpdatedDate = headHunterSnippet.UpdateDate;
            vacancy.IsArchived        = false;
            return(vacancy);
        }
Esempio n. 5
0
 private async Task <Employment> GetOrCreateEmploymentAsync(HeadHunterVacancy headHunterVacancy)
 {
     if (headHunterVacancy.Employment == null)
     {
         return(null);
     }
     return(_storageBroker.SelectAllEmployments().FirstOrDefault(e =>
                                                                 e.Code.ToLower().Equals(headHunterVacancy.Employment.Id.ToLower())) ??
            await AddEmploymentAsync(headHunterVacancy.Employment));
 }
Esempio n. 6
0
 public async Task <Schedule> GetOrCreateScheduleAsync(HeadHunterVacancy headHunterVacancy)
 {
     if (headHunterVacancy.Schedule == null)
     {
         return(null);
     }
     return(_storageBroker.SelectAllSchedules().FirstOrDefault(s =>
                                                               s.Code.ToLower().Equals(headHunterVacancy.Schedule.Id.ToLower())) ??
            await AddScheduleAsync(headHunterVacancy.Schedule));
 }
Esempio n. 7
0
 private SourceEmployer GetSourceEmployer(Employer employer, HeadHunterVacancy headHunterVacancy,
                                          SourceType sourceType)
 {
     return(new()
     {
         EmployerId = employer.Id,
         SourceId = headHunterVacancy.Employer.Id,
         SourceTypeId = sourceType.Id,
         Employer = employer
     });
 }
Esempio n. 8
0
 private SourceArea GetSourceArea(Area returnedArea, HeadHunterVacancy vacancyResponse,
                                  SourceType returnedSourceType)
 {
     return(new()
     {
         Id = 1,
         AreaId = returnedArea.Id,
         Area = returnedArea,
         SourceId = vacancyResponse.Area.Id,
         SourceTypeId = returnedSourceType.Id,
         SourceType = returnedSourceType
     });
 }
Esempio n. 9
0
        private async Task <Vacancy> CreateVacancyAsync(SourceType sourceType, HeadHunterSnippet snippet,
                                                        HeadHunterVacancy headHunterVacancy)
        {
            var currencyName = headHunterVacancy.Salary?.Currency?.Trim();
            var vacancy      = CreateVacancy(snippet, headHunterVacancy);

            vacancy.EmployerId   = (await GetOrCreateEmployerAsync(sourceType, headHunterVacancy)).Id;
            vacancy.AreaId       = (await GetOrCreateAreaAsync(sourceType, headHunterVacancy))?.Id;
            vacancy.CurrencyId   = currencyName == null ? null : (await GetOrCreateCurrencyAsync(currencyName)).Id;
            vacancy.SourceTypeId = sourceType.Id;
            vacancy.ScheduleId   = (await GetOrCreateScheduleAsync(headHunterVacancy))?.Id;
            vacancy.EmploymentId = (await GetOrCreateEmploymentAsync(headHunterVacancy))?.Id;
            vacancy.IsRemote     = headHunterVacancy.Schedule?.Id == "remote";
            return(vacancy);
        }
Esempio n. 10
0
        private async Task <Employer> GetOrCreateEmployerAsync(SourceType sourceType,
                                                               HeadHunterVacancy headHunterVacancy)
        {
            var hhEmployer = new HeadHunterEmployer
            {
                Name = headHunterVacancy.Employer.Name,
                Id   = headHunterVacancy.Employer.Id,
                Url  = headHunterVacancy.Url
            };

            hhEmployer.Id ??= "-999";

            var sourceEmployer =
                await _storageBroker.SelectSourceEmployerByIdAndTypeIdAsync(sourceType.Id,
                                                                            hhEmployer.Id) ??
                await AddSourceEmployerAsync(sourceType, hhEmployer);

            return(sourceEmployer.Employer);
        }
Esempio n. 11
0
        private static Vacancy CreateVacancy(HeadHunterSnippet snippet, HeadHunterVacancy headHunterVacancy)
        {
            var vacancy = new Vacancy
            {
                SourceId         = headHunterVacancy.Id,
                Title            = headHunterVacancy.Name,
                Descriptions     = headHunterVacancy.Description,
                Responsibilities = snippet.Responsibility,
                SalaryFrom       = headHunterVacancy.Salary?.From,
                SalaryTo         = headHunterVacancy.Salary?.To,
                IsSalaryGross    = headHunterVacancy.Salary?.IsGross,
                Url                = headHunterVacancy.Url,
                RawData            = headHunterVacancy.RawData,
                IsArchived         = snippet.Archived,
                SourceCreatedDate  = headHunterVacancy.CreatedDate,
                SourceUpdatedDate  = headHunterVacancy.UpdateDate,
                ContentUpdatedDate = headHunterVacancy.UpdateDate
            };

            return(vacancy);
        }
Esempio n. 12
0
 private Schedule GetSchedule(HeadHunterVacancy headHunterVacancyResponse)
 {
     return(new()
            { Id = 1, Code = headHunterVacancyResponse.Schedule.Id, Name = headHunterVacancyResponse.Schedule.Name });
 }
Esempio n. 13
0
 private Currency GetCurrency(HeadHunterVacancy headHunterVacancy)
 {
     return(new() { Id = 1, Name = headHunterVacancy.Salary.Currency });
 }