コード例 #1
0
        public virtual PersonalInformationViewModel Prepare([NotNull] MandatorResponse mandatorResponse, [CanBeNull] ApplicantResponse applicantResponse)
        {
            AllowEmptyGender          = mandatorResponse.PortalSettings.AllowEmptyGender;
            AvailableTitlesBeforeName = from x in mandatorResponse.TitlesBeforeName
                                        select new SelectListItem
            {
                Value = x.Name,
                Text  = x.Name
            };
            AvailableTitlesAfterName = from x in mandatorResponse.TitlesAfterName
                                       select new SelectListItem
            {
                Value = x.Name,
                Text  = x.Name
            };
            AvailableCountries = from x in mandatorResponse.Countries
                                 select new SelectListItem
            {
                Value = x,
                Text  = x
            };
            AvailableNationalities = from x in mandatorResponse.Countries
                                     select new SelectListItem
            {
                Value = x,
                Text  = x
            };

            if (applicantResponse != null)
            {
                AutoMapper.Mapper.DynamicMap(applicantResponse, this);
            }

            return(this);
        }
コード例 #2
0
 private IEnumerable<string> GetTitles(bool beforeName, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     if (beforeName)
         return _mandator.TitlesBeforeName.Select(x => x.Name);
     return _mandator.TitlesAfterName.Select(x => x.Name);
 }
コード例 #3
0
        public static string TlT(MandatorResponse mandatorResponse, string originalText)
        {
            var allTranslations = mandatorResponse.Translations;
            var matchingEntry   = allTranslations.FirstOrDefault(x => x.Texts.Any(y => y.Text.Is(originalText)));

            if (matchingEntry != null)
            {
                var currentCulture = CultureInfo.CurrentCulture.Name;

                //check for identical culture
                var matchingTranslation = matchingEntry.Texts.FirstOrDefault(x => x.Culture.Is(currentCulture));

                //check for similar culture
                matchingTranslation = matchingTranslation ?? matchingEntry.Texts.FirstOrDefault(x => x.Culture.Substring(0, 2).Is(currentCulture.Substring(0, 2)));

                //fallback to english
                matchingTranslation = matchingTranslation ?? matchingEntry.Texts.FirstOrDefault(x => x.Culture.Substring(0, 2).Is("en"));

                if (matchingTranslation != null)
                {
                    return(matchingTranslation.Text);
                }
            }
            return(originalText);
        }
コード例 #4
0
        private bool IsDocumentTypeAvailable(ApiHttpClient apiClient)
        {
            if (SubType.IsNoE())
                return false;

            _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
            return _mandator.ApplicantDocumentTypes.Any(x => x.Is(SubType));
        }
コード例 #5
0
        private bool IsKnowledgeAvailable(ApiHttpClient apiClient)
        {
            if (SubType.IsNoE())
                return false;

            _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
            return _mandator.Knowledges.Any(x => x.Is(SubType));
        }
コード例 #6
0
        private bool IsKnowledgeLevelAvailable(string value, ApiHttpClient apiClient)
        {
            if (value.IsNoE())
                return false;

            _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
            return _mandator.KnowledgeLevels.Any(x => x.Is(value));
        }
コード例 #7
0
 private IEnumerable <string> GetTitles(bool beforeName, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     if (beforeName)
     {
         return(_mandator.TitlesBeforeName.Select(x => x.Name));
     }
     return(_mandator.TitlesAfterName.Select(x => x.Name));
 }
コード例 #8
0
        private bool IsKnowledgeAvailable(ApiHttpClient apiClient)
        {
            if (SubType.IsNoE())
            {
                return(false);
            }

            _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
            return(_mandator.Knowledges.Any(x => x.Is(SubType)));
        }
コード例 #9
0
        private bool IsKnowledgeLevelAvailable(string value, ApiHttpClient apiClient)
        {
            if (value.IsNoE())
            {
                return(false);
            }

            _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
            return(_mandator.KnowledgeLevels.Any(x => x.Is(value)));
        }
コード例 #10
0
        public IndexViewModel(MandatorResponse mandatorResponse, IEnumerable <ApplicantDocumentResponse> documents)
        {
            AvailableDocumentTypes = mandatorResponse.ApplicantDocumentTypes.Select(x => new SelectListItem
            {
                Value = x,
                Text  = Translations.TlT(mandatorResponse, x)
            });

            var documentsAsList = documents.ToList();

            HasCv     = documentsAsList.Any(x => x.Id == -1);
            HasPhoto  = documentsAsList.Any(x => x.Id == -2);
            Documents = documentsAsList.Where(x => x.Id > 0).ToList();
        }
コード例 #11
0
        public IndexViewModel Fill(MandatorResponse mandatorResponse, IEnumerable <string> jobProfiles)
        {
            JobProfiles = jobProfiles.OrderBy(x => x).ToList();

            AvailableJobProfiles = (from x in mandatorResponse.JobProfiles
                                    where !JobProfiles.Any(y => y.Is(x))
                                    orderby x
                                    select new SelectListItem
            {
                Text = x,
                Value = x
            }).ToList();
            return(this);
        }
コード例 #12
0
        public RegisterViewModel Prepare(MandatorResponse mandatorResponse, JobResponse jobResponse)
        {
            if (jobResponse != null)
            {
                JobId = jobResponse.Id;
            }

            AvailableDocumentTypes = mandatorResponse.ApplicantDocumentTypes.Select(x => new SelectListItem {
                Text = x, Value = x
            }).ToList();

            base.Prepare(mandatorResponse);

            return(this);
        }
コード例 #13
0
        public async Task <IndexViewModel> Build(MandatorResponse mandator, LoadJobsService loadJobsService, Uri requestUrl)
        {
            var publishedJobs = await loadJobsService.LoadJobsForCurrentPortal(requestUrl, mandator);

            foreach (var application in Applications)
            {
                if (publishedJobs.Jobs.Any(x => x.Id == application.JobId))
                {
                    application.Job            = publishedJobs.Jobs.Single(x => x.Id == application.JobId).Title;
                    application.JobIsPublished = true;
                }
                else
                {
                    application.Job            = (await loadJobsService.LoadSingleJob(application.JobId)).Title;
                    application.JobIsPublished = false;
                }
            }

            return(this);
        }
コード例 #14
0
 private bool IsJobProfileAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.JobProfiles.Any(x => x.Is(value)));
 }
コード例 #15
0
 public virtual PersonalInformationViewModel Prepare(MandatorResponse mandatorResponse)
 {
     return(Prepare(mandatorResponse, null));
 }
コード例 #16
0
 private bool IsNationalityAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.Countries.Any(x => x.Is(value)));
 }
コード例 #17
0
 private CustomFieldResponse GetCustomField(ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.CustomFields.FirstOrDefault(x => x.Name.Is(SubType) && (x.Target == CustomFieldResponse.CustomFieldTarget.Applicant || x.Target == CustomFieldResponse.CustomFieldTarget.ApplicantCompany || x.Target == CustomFieldResponse.CustomFieldTarget.JobApplicantCompany || x.Target == CustomFieldResponse.CustomFieldTarget.JobApplicant)));
 }
コード例 #18
0
 private bool IsClassificationAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.ClassificationTypes.Any(x => x.Is(value)));
 }
コード例 #19
0
 private bool IsRegionAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(IsRegionAvailable(value, _mandator.Regions));
 }
コード例 #20
0
 private bool IsReferrerAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return _mandator.Referrers.Any(x => x.Name.Is(value));
 }
コード例 #21
0
 private bool IsRegionAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return IsRegionAvailable(value, _mandator.Regions);
 }
コード例 #22
0
 private bool IsClassificationAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return _mandator.ClassificationTypes.Any(x => x.Is(value));
 }
コード例 #23
0
 public async Task <JobsResponse> LoadJobsForCurrentPortal(Uri requestUri, MandatorResponse mandatorResponse)
 {
     return(await new JobsRequest(string.Empty).LoadResult(_client));
 }
コード例 #24
0
 public SyndicationService(MandatorResponse mandatorResponse, UrlBuilderService urlBuilder)
 {
     _urlBuilder       = urlBuilder;
     _mandatorResponse = mandatorResponse;
 }
コード例 #25
0
 public FixJobAdUrlsService(MandatorResponse mandatorResponse)
 {
     _mandatorResponse = mandatorResponse;
 }
コード例 #26
0
        public async Task <ApplicantResponse> LinkProfileToApplicant([NotNull] ApiHttpClient apiClient, [NotNull] MandatorResponse mandatorResponse, [CanBeNull] ApplicantResponse loggedInApplicantResponse, [NotNull] IProfile profile, ThirdParty thirdParty)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            ApplicantResponse applicant;

            try
            {
                applicant = loggedInApplicantResponse ?? await new ApplicantGetRequest(profile.Id, thirdParty).LoadResult(apiClient);
            }
            catch
            {
                applicant = null;
            }

            //we don't have an applicant that is logged in or has a matching profile
            //so, lets create a new applicant
            if (applicant == null)
            {
                //this should never happen, because we catch this case earlier, before calling this method
                //this is just to make absolutely sure ;)
                if (await IsEmailAddressAlreadyInUse(apiClient, mandatorResponse, profile.Email))
                {
                    return(null);
                }

                bool?gender = null;
                if (profile.Gender == Gender.Female)
                {
                    gender = false;
                }
                else if (profile.Gender == Gender.Male)
                {
                    gender = true;
                }

                var parameter = new ApplicantParameter
                {
                    Email     = profile.Email,
                    FirstName = profile.FirstName,
                    LastName  = profile.LastName,
                    Gender    = gender
                };
                applicant = await new ApplicantPutRequest(parameter).LoadResult(apiClient);
            }

            //now link the profile
            var linkRequest = thirdParty == ThirdParty.Xing
                                  ? new LinkXingRequest(applicant.Id, profile.Id, profile.Url)
                                  : (HttpRequestMessage <ApplicantResponse>) new LinkLinkedInRequest(applicant.Id, profile.Id, profile.Url);

            applicant = await linkRequest.LoadResult(apiClient);

            return(applicant);
        }
コード例 #27
0
 private bool IsCareerlevelAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.CareerLevels.Any(x => x.Is(value)));
 }
コード例 #28
0
 private bool IsReferrerAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return(_mandator.Referrers.Any(x => x.Name.Is(value)));
 }
コード例 #29
0
 private CustomFieldResponse GetCustomField(ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return _mandator.CustomFields.FirstOrDefault(x => x.Name.Is(SubType) && (x.Target == CustomFieldResponse.CustomFieldTarget.Applicant || x.Target == CustomFieldResponse.CustomFieldTarget.ApplicantCompany || x.Target == CustomFieldResponse.CustomFieldTarget.JobApplicantCompany || x.Target == CustomFieldResponse.CustomFieldTarget.JobApplicant));
 }
コード例 #30
0
 public async Task <ApplicantResponse> LinkProfileToApplicant([NotNull] ApiHttpClient apiClient, [NotNull] MandatorResponse mandatorResponse, [NotNull] IProfile profile, ThirdParty thirdParty)
 {
     return(await LinkProfileToApplicant(apiClient, mandatorResponse, null, profile, thirdParty));
 }
コード例 #31
0
 public async Task <bool> IsEmailAddressAlreadyInUse([NotNull] ApiHttpClient apiClient, [NotNull] MandatorResponse mandatorResponse, string email)
 {
     //check if the email is not in use already
     if (!mandatorResponse.PortalSettings.AllowDuplicateEmail)
     {
         var applicantsWithThisEmail = await new ApplicantsRequest(email).LoadResult(apiClient);
         return(applicantsWithThisEmail.Any());
     }
     return(false);
 }
コード例 #32
0
 private bool IsCountryAvailable(string value, ApiHttpClient apiClient)
 {
     _mandator = _mandator ?? new MandatorRequest().LoadResult(apiClient);
     return _mandator.Countries.Any(x => x.Is(value));
 }
コード例 #33
0
        protected async Task <JobResponse> GetJob(MandatorResponse mandatorResponse, LoadJobsService jobsService, int jobId)
        {
            var jobsResponse = await jobsService.LoadJobsForCurrentPortal(Request.Url, mandatorResponse);

            return(jobsResponse.Jobs.FirstOrDefault(x => x.Id == jobId));
        }