public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsClassificationAvailable(value, apiClient))
     {
         applicant.Classification = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsCountryAvailable(value, apiClient))
     {
         applicant.Country = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         applicant.ReferrerAdditionalInfo = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsNationalityAvailable(value, apiClient))
     {
         applicant.Citizenship = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         applicant.ClassificationReason = value;
     }
 }
Example #6
0
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsCareerlevelAvailable(value, apiClient))
     {
         applicant.CareerLevel = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsNationalityAvailable(value, apiClient))
     {
         applicant.Citizenship = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsReferrerAvailable(value, apiClient))
     {
         applicant.Referrer = value;
     }
 }
Example #9
0
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         applicant.Street = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         applicant.ReferrerAdditionalInfo = value;
     }
 }
Example #11
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);
        }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var date = ParseDate(value);
         if (date != null)
             applicant.EarliestPossibleBeginDate = new FlexDate(date.Value);
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var date = ParseDate(value);
         if (date != null)
             applicant.BirthDate = date.Value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsJobProfileAvailable(value, apiClient))
     {
         var jobProfiles = (applicant.JobProfiles ?? new List <string>()).ToList();
         jobProfiles.Add(value);
         applicant.JobProfiles = jobProfiles;
     }
 }
Example #15
0
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsRegionAvailable(value, apiClient))
     {
         var regions = (applicant.Regions ?? new List <string>()).ToList();
         regions.Add(value);
         applicant.Regions = regions;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsJobProfileAvailable(value, apiClient))
     {
         var jobProfiles = (applicant.JobProfiles ?? new List<string>()).ToList();
         jobProfiles.Add(value);
         applicant.JobProfiles = jobProfiles;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue() && IsRegionAvailable(value, apiClient))
     {
         var regions = (applicant.Regions ?? new List<string>()).ToList();
         regions.Add(value);
         applicant.Regions = regions;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         if (IsTitleAfterNameAvailable(value, apiClient))
             applicant.TitleAfterName = value;
         else if (IsTitleBeforeNameAvailable(value, apiClient))
             applicant.TitleBeforeName = value;
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var date = ParseDate(value);
         if (date != null)
         {
             applicant.EarliestPossibleBeginDate = new FlexDate(date.Value);
         }
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var date = ParseDate(value);
         if (date != null)
         {
             applicant.BirthDate = date.Value;
         }
     }
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var gender = Gender.Unknown;
         if (_maleValues.Any(x => x.Is(value)))
             gender = Gender.Male;
         else if (_femaleValues.Any(x => x.Is(value)))
             gender = Gender.Female;
         applicant.Gender = gender;
     }
 }
Example #22
0
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         if (IsTitleAfterNameAvailable(value, apiClient))
         {
             applicant.TitleAfterName = value;
         }
         else if (IsTitleBeforeNameAvailable(value, apiClient))
         {
             applicant.TitleBeforeName = value;
         }
     }
 }
Example #23
0
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
     {
         var gender = Gender.Unknown;
         if (_maleValues.Any(x => x.Is(value)))
         {
             gender = Gender.Male;
         }
         else if (_femaleValues.Any(x => x.Is(value)))
         {
             gender = Gender.Female;
         }
         applicant.Gender = gender;
     }
 }
Example #24
0
        public async Task <ApplicantResponse> UpdatePersonalInformation(ApiHttpClient apiClient, ApplicantResponse applicantResponse, PersonalInformationViewModel model)
        {
            //set the remaining applicant data by updating it
            var updateParameter = new ApplicantParameter(applicantResponse)
            {
                BirthDate       = model.BirthDate,
                City            = model.City,
                Country         = model.Country,
                Nationality     = model.Nationality,
                Phone           = model.Phone,
                Street          = model.Street,
                TitleBeforeName = model.TitleBeforeName,
                TitleAfterName  = model.TitleAfterName,
                ZipCode         = model.ZipCode,
                Email           = model.Email
            };

            return(await new ApplicantPostRequest(applicantResponse.Id, updateParameter).LoadResult(apiClient));
        }
 public virtual void SetValueBeforeCreate([CanBeNull] string value, [NotNull] ApplicantParameter applicant,
                                          [NotNull] ApiHttpClient apiClient)
 {
 }
 public override void SetValueBeforeCreate(string value, ApplicantParameter applicant, ApiHttpClient apiClient)
 {
     if (value.HasValue())
         applicant.ZipCode = value;
 }
        public void RunImport(out bool hasErrors)
        {
            hasErrors = false;

            var apiClient = ApiClientFactory.GetClient(_configuration);

            var count = 0;
            var total = _csv.Values.Count();

            foreach (var row in _csv.Values)
            {
                ApplicantParameter applicantParameter;
                ApplicantResponse  applicantResponse;

                var idColumn            = _configuration.Columns.FirstOrDefault(x => x.Type == ColumnType.Id);
                int?existingApplicantId = null;
                if (idColumn != null && row.ContainsKey(idColumn.Header) && row[idColumn.Header].ToString().IsInt())
                {
                    existingApplicantId = row[idColumn.Header].ToString().GetInt();
                    Program.Write($"Updating applicant #{existingApplicantId} {++count}/{total} ...");

                    applicantResponse  = new ApplicantGetRequest(existingApplicantId.Value).LoadResult(apiClient);
                    applicantParameter = new ApplicantParameter(applicantResponse);
                }
                else
                {
                    Program.Write($"Creating applicant {++count}/{total} ...");
                    applicantParameter = new ApplicantParameter
                    {
                        FirstName = "First-Name",
                        LastName  = "Last-Name",
                        IsActive  = true
                    };
                }

                try
                {
                    foreach (var c in _configuration.Columns)
                    {
                        var column = ColumnFactory.GetColumn(c);
                        column.SetValueBeforeCreate(row.ContainsKey(c.Header) ? row[c.Header] as string : null,
                                                    applicantParameter, apiClient);
                    }

                    if (existingApplicantId.HasValue)
                    {
                        applicantResponse =
                            new ApplicantPostRequest(existingApplicantId.Value, applicantParameter).LoadResult(apiClient);
                        Program.Write(
                            $"Applicant '#{applicantResponse.Id} {applicantResponse.FirstName} {applicantResponse.LastName}' updated. Setting additional attributes ...");
                    }
                    else
                    {
                        applicantResponse =
                            new ApplicantPutRequest(applicantParameter, false, new Uri("http://does_not_matter"))
                            .LoadResult(apiClient);
                        Program.Write(
                            $"Applicant '#{applicantResponse.Id} {applicantResponse.FirstName} {applicantResponse.LastName}' created. Setting additional attributes ...");
                    }

                    foreach (var c in _configuration.Columns)
                    {
                        var column = ColumnFactory.GetColumn(c);
                        column.SetValueAfterCreate(row.ContainsKey(c.Header) ? row[c.Header] as string : null,
                                                   applicantResponse, apiClient);
                    }

                    Program.Write("");
                }
                catch (Exception ex)
                {
                    Program.WriteError("Unable to import applicant: " + ex.Message);
                    hasErrors = true;
                    return;
                }
            }
        }
Example #28
0
 public ApplicantPutRequest(ApplicantParameter applicant)
     : base("Applicant/", applicant)
 {
 }
Example #29
0
 public ApplicantPutRequest(ApplicantParameter applicant, bool sendRegistrationEmail, Uri currentUrl)
     : base("Api/Applicant/?sendRegistrationEmail=" + sendRegistrationEmail + "&url=" + currentUrl, applicant)
 {
 }
Example #30
0
 public ApplicantPostRequest(int applicantId, ApplicantParameter applicant)
     : base("Api/Applicant/" + applicantId, applicant)
 {
 }
        public void RunImport(out bool hasErrors)
        {
            hasErrors = false;

            var apiClient = ApiClientFactory.GetClient(_configuration);

            var count = 0;
            var total = _csv.Values.Count();
            foreach (var row in _csv.Values)
            {
                ApplicantParameter applicantParameter;
                ApplicantResponse applicantResponse;

                var idColumn = _configuration.Columns.FirstOrDefault(x => x.Type == ColumnType.Id);
                int? existingApplicantId = null;
                if (idColumn != null && row.ContainsKey(idColumn.Header) && row[idColumn.Header].ToString().IsInt())
                {
                    existingApplicantId = row[idColumn.Header].ToString().GetInt();
                    Program.Write($"Updating applicant #{existingApplicantId} {++count}/{total} ...");

                    applicantResponse = new ApplicantGetRequest(existingApplicantId.Value).LoadResult(apiClient);
                    applicantParameter = new ApplicantParameter(applicantResponse);
                }
                else
                {
                    Program.Write($"Creating applicant {++count}/{total} ...");
                    applicantParameter = new ApplicantParameter
                    {
                        FirstName = "First-Name",
                        LastName = "Last-Name",
                        IsActive = true
                    };
                }

                try
                {
                    foreach (var c in _configuration.Columns)
                    {
                        var column = ColumnFactory.GetColumn(c);
                        column.SetValueBeforeCreate(row.ContainsKey(c.Header) ? row[c.Header] as string : null,
                            applicantParameter, apiClient);
                    }

                    if (existingApplicantId.HasValue)
                    {
                        applicantResponse =
                            new ApplicantPostRequest(existingApplicantId.Value, applicantParameter).LoadResult(apiClient);
                        Program.Write(
                            $"Applicant '#{applicantResponse.Id} {applicantResponse.FirstName} {applicantResponse.LastName}' updated. Setting additional attributes ...");
                    }
                    else
                    {
                        applicantResponse =
                            new ApplicantPutRequest(applicantParameter, false, new Uri("http://does_not_matter"))
                                .LoadResult(apiClient);
                        Program.Write(
                            $"Applicant '#{applicantResponse.Id} {applicantResponse.FirstName} {applicantResponse.LastName}' created. Setting additional attributes ...");
                    }

                    foreach (var c in _configuration.Columns)
                    {
                        var column = ColumnFactory.GetColumn(c);
                        column.SetValueAfterCreate(row.ContainsKey(c.Header) ? row[c.Header] as string : null,
                            applicantResponse, apiClient);
                    }

                    Program.Write("");
                }
                catch (Exception ex)
                {
                    Program.WriteError("Unable to import applicant: " + ex.Message);
                    hasErrors = true;
                    return;
                }
            }
        }
Example #32
0
        public async Task <ActionResult> Register(int?job, RegisterViewModel model)
        {
            var mandator = await GetMandator();

            model.Prepare(mandator, job.HasValue ? await GetJob(mandator, _jobsService, job.Value) : null);

            if (model.Cv != null && _updateApplicantFileService.CheckFile(model.Cv, "Cv") != UpdateApplicantFileService.CheckFileResult.Ok)
            {
                ModelState.AddModelError("Cv", @"Error-Cv");
            }
            if (model.Photo != null && _updateApplicantFileService.CheckFile(model.Photo, "Photo") != UpdateApplicantFileService.CheckFileResult.Ok)
            {
                ModelState.AddModelError("Photo", @"Error-Photo");
            }
            if (model.Documents != null)
            {
                var index = 0;
                foreach (var document in model.Documents)
                {
                    if (document != null && _updateApplicantFileService.CheckFile(document, model.DocumentTypes.ElementAt(index)) != UpdateApplicantFileService.CheckFileResult.Ok)
                    {
                        ModelState.AddModelError("Documents", @"Error-Documents");
                        break;
                    }
                    index++;
                }
            }

            if (ModelState.IsValid)
            {
                //check if the email is not in use already
                if (!mandator.PortalSettings.AllowDuplicateEmail)
                {
                    var applicantsWithThisEmail = await new ApplicantsRequest(model.Email).LoadResult(ApiClient);
                    if (applicantsWithThisEmail.Any())
                    {
                        return(RedirectToAction("EmailAlreadyInUse", "Account", new { job, email = model.Email }));
                    }
                }

                //create the applicant
                var createParameter = new ApplicantParameter
                {
                    Email     = model.Email,
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Gender    = model.Gender
                };
                var applicant = await new ApplicantPutRequest(createParameter).LoadResult(ApiClient);

                //update the personal information
                applicant = await _updateApplicantService.UpdatePersonalInformation(ApiClient, applicant, model);

                //save the documents
                if (model.Cv != null)
                {
                    await _updateApplicantFileService.AddCv(ApiClient, applicant, model.Cv);
                }
                if (model.Photo != null)
                {
                    await _updateApplicantFileService.AddPhoto(ApiClient, applicant, model.Photo);
                }
                if (model.Documents != null)
                {
                    var index = 0;
                    foreach (var document in model.Documents)
                    {
                        if (document != null)
                        {
                            await _updateApplicantFileService.AddFile(ApiClient, applicant, document, model.DocumentTypes.ElementAt(index));
                        }
                        index++;
                    }
                }

                //log the applicant in and redirect either to the applicant profile or the application page
                FormsAuthentication.SetAuthCookie(applicant.Id.ToString(CultureInfo.InvariantCulture), false);
                if (job.HasValue)
                {
                    return(RedirectToAction("Index", "Application", new { job }));
                }
                return(RedirectToAction("RegisterSuccess"));
            }
            return(View(model));
        }