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 + ")"));
        }
示例#2
0
        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);
        }
示例#3
0
        private Member CreateShortlistedCandidate(IEmployer employer, JobAdEntry jobAd, int index)
        {
            var member = CreateMember(index);

            _jobAdApplicationsCommand.ShortlistApplicants(employer, jobAd, new[] { member.Id });
            return(member);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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());
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
 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;
 }
示例#10
0
        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);
        }
示例#11
0
 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)));
 }
示例#12
0
        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);
        }
示例#13
0
 private static int GetDaysUntilExpiry(JobAdEntry jobAd)
 {
     return(jobAd.ExpiryTime == null
         ? 0
         : jobAd.ExpiryTime.Value > DateTime.Now
             ? (jobAd.ExpiryTime.Value - DateTime.Now).Days
             : 0);
 }
示例#14
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;
 }
示例#15
0
 void IEmployerJobAdsCommand.CloseJobAd(IEmployer employer, JobAdEntry jobAd)
 {
     if (!CanAccess(employer, jobAd))
     {
         throw new JobAdPermissionsException(employer, jobAd.Id);
     }
     _jobAdsCommand.CloseJobAd(jobAd);
 }
示例#16
0
        private void Submit(Guid memberId, JobAdEntry jobAd)
        {
            var application = new InternalApplication {
                ApplicantId = memberId
            };

            _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
            _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
        }
示例#17
0
        protected void SubmitApplication(IMember member, JobAdEntry jobAd)
        {
            var application = new InternalApplication {
                ApplicantId = member.Id
            };

            _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application);
            _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
        }
示例#18
0
        private bool IsExcluded(JobAdEntry jobAd)
        {
            if (jobAd.Integration == null || jobAd.Integration.IntegratorUserId == null)
            {
                return(false);
            }

            return(_excludedIntegratorIds.Contains(jobAd.Integration.IntegratorUserId.Value));
        }
示例#19
0
        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));
        }
示例#20
0
 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>");
 }
示例#21
0
        protected Application ApplyForInternalJob(JobAdEntry jobAd, Guid applicantId)
        {
            var application = new InternalApplication {
                ApplicantId = applicantId
            };

            _jobAdsApplicationSubmissionsCommand.CreateApplication(jobAd, application);
            _jobAdsApplicationSubmissionsCommand.SubmitApplication(jobAd, application);
            return(application);
        }
示例#22
0
        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();
        }
示例#23
0
        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);
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        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;
        }
示例#27
0
        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;
        }
示例#28
0
        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);
            }
        }
示例#29
0
        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");
        }
示例#30
0
        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();
                }
            }
        }