private static string GetSubject(JobAdEntry jobAd) { var externalReferenceId = jobAd.Integration.ExternalReferenceId; return((string.IsNullOrEmpty(externalReferenceId) ? "" : "[" + externalReferenceId + "] ") + string.Format("Application for {0}{1}", jobAd.Title, string.IsNullOrEmpty(externalReferenceId) ? string.Empty : " (ref# " + externalReferenceId + ")")); }
string ISendJobG8Command.SendApplication(ICommunicationUser user, JobAdEntry jobAd, string resumeFileName, FileContents resumeContents, InternalApplication application, IEnumerable <ApplicationAnswer> answers) { var request = new UploadRequestMessage { Body = new UploadRequestBody { ApplicationXml = Serialize(CreateApplicationResponse(user, jobAd, resumeFileName, resumeContents, application, answers)) } }; string result; var service = _serviceManager.Create(); try { var response = service.Send(request); result = response.Body.Result; } catch (Exception) { _serviceManager.Abort(service); throw; } _serviceManager.Close(service); return(result); }
private Member CreateShortlistedCandidate(IEmployer employer, JobAdEntry jobAd, int index) { var member = CreateMember(index); _jobAdApplicationsCommand.ShortlistApplicants(employer, jobAd, new[] { member.Id }); return(member); }
bool IExternalJobAdsCommand.CanCreateJobAd(JobAdEntry jobAd) { var equivalentJobAds = GetEquivalentJobAds(jobAd); if (equivalentJobAds.Count == 0) { return(true); } // The job ads must be either Draft or Open. equivalentJobAds = (from j in equivalentJobAds where j.Status == JobAdStatus.Draft || j.Status == JobAdStatus.Open select j).ToList(); if (equivalentJobAds.Count == 0) { return(true); } // If it has higher priority then any of the equivalent job ads then ... if (HasHigherPriority(jobAd, equivalentJobAds)) { // Then close those equivalent job ads so this job ad can replace them. foreach (var equivalentJobAd in equivalentJobAds) { _jobAdsCommand.CloseJobAd(equivalentJobAd); } return(true); } return(false); }
private bool IsExcluded(JobAdEntry jobAd) { if (jobAd.Status != JobAdStatus.Open) { return(true); } if (jobAd.Integration == null || jobAd.Integration.IntegratorUserId == null) { return(false); } if (_excludedIntegratorIds.Contains(jobAd.Integration.IntegratorUserId.Value)) { return(true); } // Do not export community job ads. var employer = _employersQuery.GetEmployer(jobAd.PosterId); if (employer == null) { return(false); } return(((IEmployer)employer).AffiliateId != null); }
private string GetContent(TemplateEmail templateEmail, string messageText, JobAdEntry ad) { var builder = new StringBuilder(); builder.AppendLine("<p>Hi " + RecipientDisplayName + "</p>"); builder.AppendLine("<p>"); builder.AppendLine(" " + SenderDisplayName + " has found an interesting job "); builder.AppendLine(" opportunity and thought that you should see it."); builder.AppendLine("</p>"); builder.AppendLine(); if (!string.IsNullOrEmpty(messageText)) { builder.AppendLine("<p>"); builder.AppendLine(" " + SenderDisplayName + "'s personal message:"); builder.AppendLine(" <br />"); builder.AppendLine(" " + messageText); builder.AppendLine("</p>"); builder.AppendLine(); } builder.AppendLine("<p>"); builder.AppendLine(" View the "); builder.AppendLine(" <a href=\"" + GetTinyUrl(templateEmail, false, "~/jobs/" + ad.Id) + "\">" + ad.Title + "</a>"); builder.AppendLine(" job and apply now."); builder.AppendLine("</p>"); return(builder.ToString()); }
private void AssertApplication(Guid applicationId, JobAdEntry jobAd, Guid applicantId, string coverLetterText, Guid resumeId) { var application = AssertApplication(applicationId, jobAd, applicantId, coverLetterText); Assert.AreEqual(resumeId, application.ResumeId); Assert.IsNull(application.ResumeFileId); }
private void AssertJobG8Request(ICommunicationRecipient user, JobAdEntry jobAd, InternalApplication application, string resumeFileName, string resumeValue) { var requests = _jobG8Server.GetRequests(); Assert.AreEqual(1, requests.Count); var response = Deserialize <ApplicationResponse>(requests[0].Body.ApplicationXml); Assert.AreEqual(jobAd.Integration.JobBoardId, response.ApplicationAnswer.JobBoardID); Assert.AreEqual(jobAd.Integration.IntegratorReferenceId, response.ApplicationAnswer.JobReference); // FirstName, LastName, EmailAddress + whichever questions have values. var count = 3 + (from q in _questionTesters where q.Value != null select q).Count(); Assert.AreEqual(count, response.ApplicationAnswer.Questions.Question.Length); AssertFirstName(user.FirstName, response); AssertLastName(user.LastName, response); AssertEmailAddress(user.EmailAddress, response); AssertQuestions(response); AssertCoverLetter(application.CoverLetterText, response); AssertResume(resumeFileName, resumeValue, response); }
private static void MapTo(this JobAdEntry jobAd, IHaveIntegrationEntity entity) { entity.integratorUserId = jobAd.Integration.IntegratorUserId; entity.externalReferenceId = jobAd.Integration.ExternalReferenceId; entity.externalApplyUrl = jobAd.Integration.ExternalApplyUrl; entity.integratorReferenceId = jobAd.Integration.IntegratorReferenceId; }
private bool ShouldSend(JobAdEntry jobAd, InternalApplication application) { // Do not send an email to the job poster if the job ad is external. // It is assumed that submitting the external application will send them a notification. return(_jobAdProcessingQuery.GetJobAdProcessing(jobAd) == JobAdProcessing.ManagedInternally && !application.IsPending); }
private static ReadOnlyUrl GetRedirectedUrl(JobAdEntry jobAd, Guid applicationId) { return(new ReadOnlyUrl( jobAd.Integration.ExternalApplyUrl, new ReadOnlyQueryString( "linkmeApplicationId", applicationId.ToString("n"), "linkmeApplicationUri", new ReadOnlyApplicationUrl(true, "~/jobapplication/" + applicationId).AbsoluteUri))); }
protected InternalApplication AssertInternalApplication(Guid applicationId, JobAdEntry jobAd, Guid applicantId, bool isPending, bool hasSubmitted, string coverLetterText, Action <InternalApplication> assertApplication) { var application = _memberApplicationsQuery.GetInternalApplication(applicationId); AssertApplication(application, applicationId, jobAd.Id, applicantId, a => AssertInternalApplication(a, isPending, coverLetterText, assertApplication)); Assert.AreEqual(hasSubmitted, _jobAdApplicationSubmissionsQuery.HasSubmittedApplication(applicantId, jobAd.Id)); return(application); }
private static int GetDaysUntilExpiry(JobAdEntry jobAd) { return(jobAd.ExpiryTime == null ? 0 : jobAd.ExpiryTime.Value > DateTime.Now ? (jobAd.ExpiryTime.Value - DateTime.Now).Days : 0); }
public SendJobToFriendEmail(string toEmailAddress, string toDisplayName, string fromEmailAddress, string fromDisplayName, JobAdEntry ad, string messageText) : base(GetUnregisteredMember(toEmailAddress, toDisplayName), GetUnregisteredMember(fromEmailAddress, fromDisplayName)) { _jobAd = ad; _messageText = messageText; _fromDisplayName = fromDisplayName; _toDisplayName = toDisplayName; }
void IEmployerJobAdsCommand.CloseJobAd(IEmployer employer, JobAdEntry jobAd) { if (!CanAccess(employer, jobAd)) { throw new JobAdPermissionsException(employer, jobAd.Id); } _jobAdsCommand.CloseJobAd(jobAd); }
private void Submit(Guid memberId, JobAdEntry jobAd) { var application = new InternalApplication { ApplicantId = memberId }; _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application); }
protected void SubmitApplication(IMember member, JobAdEntry jobAd) { var application = new InternalApplication { ApplicantId = member.Id }; _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application); }
private bool IsExcluded(JobAdEntry jobAd) { if (jobAd.Integration == null || jobAd.Integration.IntegratorUserId == null) { return(false); } return(_excludedIntegratorIds.Contains(jobAd.Integration.IntegratorUserId.Value)); }
protected void AssertRedirectToExternal(bool isLoggedIn, Guid applicationId, JobAdEntry jobAd) { var redirectUrl1 = GetRedirectToExternalUrl(jobAd.Id, applicationId); var redirectUrl2 = GetRedirectToExternalUrl(jobAd.Id); Get(redirectUrl1); AssertUrl(GetRedirectedUrl(jobAd, applicationId)); Get(redirectUrl2); AssertUrl(isLoggedIn ? GetRedirectedUrl(jobAd, applicationId) : GetRedirectedUrl(jobAd)); }
protected void AssertPublishPage(JobAdEntry jobAd, JobAdFeatures features) { AssertUrlWithoutQuery(GetSuggestedCandidatesUrl(jobAd.Id)); AssertConfirmationMessage( "<p>\'" + HtmlUtil.HtmlToText(jobAd.Title) + "\' was successfully published.</p><p>It will expire on <b>" + DateTime.Now.Date.AddDays(features.IsFlagSet(JobAdFeatures.ExtendedExpiry) ? 30 : 14).ToShortDateString() + "</b>.</p>"); }
protected Application ApplyForInternalJob(JobAdEntry jobAd, Guid applicantId) { var application = new InternalApplication { ApplicantId = applicantId }; _jobAdsApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdsApplicationSubmissionsCommand.SubmitApplication(jobAd, application); return(application); }
private void AssertPostCredits(IUser administrator, IEmployer employer, JobAdEntry jobAd, Allocation initialJobAdAllocation, Allocation initialApplicantAllocation) { var allocations = GetAllocations(initialJobAdAllocation, initialApplicantAllocation); // Determine whether allocations have been created. Allocation usedJobAdAllocation; if (initialJobAdAllocation == null) { usedJobAdAllocation = _allocationsQuery.GetAllocationsByOwnerId <JobAdCredit>(employer.Id).Single(); allocations.Add(usedJobAdAllocation); } else { if (initialJobAdAllocation.InitialQuantity == 0) { usedJobAdAllocation = _allocationsQuery.GetAllocationsByOwnerId <JobAdCredit>(employer.Id).Single(a => a.Id != initialJobAdAllocation.Id); allocations.Add(usedJobAdAllocation); } else { usedJobAdAllocation = initialJobAdAllocation; if (usedJobAdAllocation.InitialQuantity != null && usedJobAdAllocation.InitialQuantity != 0) { usedJobAdAllocation.RemainingQuantity -= 1; } } } if (initialApplicantAllocation == null) { allocations.Add(_allocationsQuery.GetAllocationsByOwnerId <ApplicantCredit>(employer.Id).Single()); } else if (initialApplicantAllocation.InitialQuantity == 0) { allocations.Add(_allocationsQuery.GetAllocationsByOwnerId <ApplicantCredit>(employer.Id).Single(a => a.Id != initialApplicantAllocation.Id)); } LogIn(administrator); // Check who the employer has exercised credits on. AssertEmployerCreditUsage <JobAdCredit>(employer, (ICreditOwner)employer, true, new UsedOnJobAd(jobAd)); // Check their credits. AssertEmployerCredits(employer, allocations.ToArray()); // Check the allocation. AssertEmployerCreditUsage(employer, usedJobAdAllocation, true, new UsedOnJobAd(jobAd)); LogOut(); }
private Member CreateNewCandidate(JobAdEntry jobAd, int index) { var member = CreateMember(index); var application = new InternalApplication { ApplicantId = member.Id }; _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application); return(member); }
private Member CreateRejectedCandidate(IEmployer employer, JobAdEntry jobAd, int index) { var member = CreateMember(index); var application = new InternalApplication { ApplicantId = member.Id }; _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application); _jobAdApplicationsCommand.RejectApplicants(employer, jobAd, new[] { member.Id }); return(member); }
public static void MapTo(this JobAdEntry jobAd, JobAdEntity entity) { entity.expiryTime = jobAd.ExpiryTime; entity.lastUpdatedTime = jobAd.LastUpdatedTime; entity.title = jobAd.Title; entity.isFeatured = (byte)jobAd.FeatureBoost; entity.features = (int)jobAd.Features; entity.brandingLogoImageId = jobAd.LogoId; entity.hideContactDetails = jobAd.Visibility.HideContactDetails; entity.hideCompany = jobAd.Visibility.HideCompany; ((IHaveContactDetails)jobAd).MapTo(entity); jobAd.MapTo((IHaveIntegrationEntity)entity); }
void IJobAdsCommand.TransferJobAd(Guid toPosterId, JobAdEntry jobAd) { if (toPosterId == jobAd.PosterId) { return; } if (!CanBeTransferred(jobAd)) { throw new InvalidOperationException(string.Format("Cannot transfer the '{0}' job ad.", jobAd.Id)); } _repository.TransferJobAd(toPosterId, jobAd.Id); jobAd.PosterId = toPosterId; }
void IJobAdsCommand.DeleteJobAd(JobAdEntry jobAd) { if (jobAd.Status == JobAdStatus.Deleted) { return; } if (!CanBeDeleted(jobAd)) { throw new InvalidOperationException(string.Format("Cannot delete the '{0}' job ad.", jobAd.Id)); } _repository.DeleteRefresh(jobAd.Id); _repository.ChangeStatus(jobAd.Id, JobAdStatus.Deleted, null, DateTime.Now); jobAd.Status = JobAdStatus.Deleted; }
private JobAd GetExistingJobAd(Guid jobPosterId, JobAdEntry jobAd) { var existingJobAd = _externalJobAdsCommand.GetExistingJobAd(jobAd.Integration.IntegratorUserId.Value, jobPosterId, jobAd.Integration.ExternalReferenceId); if (existingJobAd == null) { return(null); } // Must be either a draft or open job ad. switch (jobAd.Status) { case JobAdStatus.Draft: switch (existingJobAd.Status) { case JobAdStatus.Draft: return(existingJobAd); case JobAdStatus.Open: // Want to turn an open job ad into a draft one. Close the original so a new draft version can be created. _jobAdsCommand.CloseJobAd(existingJobAd); return(null); default: return(null); } case JobAdStatus.Open: switch (existingJobAd.Status) { case JobAdStatus.Draft: case JobAdStatus.Open: case JobAdStatus.Closed: return(existingJobAd); default: return(null); } default: return(null); } }
private static string GetStatusText(JobAdEntry jobAd, Application application) { if (application is ExternalApplication) { return("Managed externally"); } if (((InternalApplication)application).IsPending) { return(!string.IsNullOrEmpty(jobAd.Integration.ExternalApplyUrl) ? "Pending (external site)Complete application" : "Managed externally"); } return("New"); }
void IJobAdsRepository.UpdateJobAd(JobAdEntry jobAd) { using (var dc = CreateContext()) { var entity = GetJobAdEntryEntity(dc, jobAd.Id); if (entity != null) { // Delete the child objects if needed. dc.CheckDeleteContactDetails(jobAd, entity); jobAd.MapTo(entity); dc.SubmitChanges(); } } }