示例#1
0
        public ActionResult ReopenJobAd(Guid jobAdId)
        {
            var employer = CurrentEmployer;

            var jobAd = GetJobAd(employer.Id, jobAdId);

            if (jobAd == null)
            {
                return(NotFound("job ad", "id", jobAdId));
            }

            try
            {
                // Open the job ad.

                _employerJobAdsCommand.OpenJobAd(employer, jobAd, true);

                // Redirect.

                return(RedirectToUrlWithConfirmation(NavigationManager.GetUrlForPage <EmployerJobAds>(), "\'" + HtmlUtil.HtmlToText(jobAd.Title) + "\' has been reopened."));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(View(GetPreviewJobAdModel(employer, jobAd, JobAdFeaturePack.BaseFeaturePack)));
        }
示例#2
0
        private void TestOpenJobAd(bool allocate, int?jobAdCredits, int?applicantCredits)
        {
            var employer = CreateEmployer(allocate, jobAdCredits, applicantCredits);
            var jobAd    = CreateJobAd(employer.Id, 0);

            // Create and open the job ad.

            _employerJobAdsCommand.CreateJobAd(employer, jobAd);
            _employerJobAdsCommand.OpenJobAd(employer, jobAd, false);

            // Check.

            AssertJobAd(jobAd, _employerJobAdsQuery.GetJobAd <JobAd>(employer, jobAd.Id));
            AssertAllocation(jobAdCredits);
        }
示例#3
0
        protected JobAd CreateJobAd(IEmployer employer, JobAdStatus status)
        {
            var jobAd = employer.CreateTestJobAd();

            _employerJobAdsCommand.CreateJobAd(employer, jobAd);

            switch (status)
            {
            case JobAdStatus.Open:
                _employerJobAdsCommand.OpenJobAd(employer, jobAd, false);
                break;

            case JobAdStatus.Closed:
                _employerJobAdsCommand.OpenJobAd(employer, jobAd, false);
                _employerJobAdsCommand.CloseJobAd(employer, jobAd);
                break;
            }

            return(jobAd);
        }
示例#4
0
        public void TestDailyLimit()
        {
            var employer = CreateEmployer();
            var counts   = _jobAdsQuery.GetOpenJobAdCounts(employer.Id);

            Assert.AreEqual(0, counts.Item1);
            Assert.AreEqual(0, counts.Item2);

            JobAd jobAd;

            try
            {
                for (var index = 0; index < DailyLimit; ++index)
                {
                    jobAd = CreateJobAd(employer.Id, 0);

                    // Create and open the job ad.

                    _employerJobAdsCommand.CreateJobAd(employer, jobAd);
                    _employerJobAdsCommand.OpenJobAd(employer, jobAd, true);

                    // Check.

                    AssertJobAd(jobAd, _employerJobAdsQuery.GetJobAd <JobAd>(employer, jobAd.Id));
                }
            }
            catch (Exception)
            {
                Assert.Fail("Too soon.");
            }

            // One more.

            jobAd = CreateJobAd(employer.Id, 0);

            // Create and open the job ad.

            _employerJobAdsCommand.CreateJobAd(employer, jobAd);
            _employerJobAdsCommand.OpenJobAd(employer, jobAd, true);
        }
示例#5
0
        private void CreateJobAd(IEmployer jobPoster, JobAd jobAd, PostReport report)
        {
            try
            {
                if (!CleanJobAd(jobAd, report))
                {
                    return;
                }

                // Need to check whether the same job ad has come in through any other integrator.

                if (!_externalJobAdsCommand.CanCreateJobAd(jobAd))
                {
                    return;
                }

                // Create the job ad.

                var status = jobAd.Status;
                jobAd.Features     = _jobAdIntegrationQuery.GetDefaultFeatures();
                jobAd.FeatureBoost = _jobAdIntegrationQuery.GetDefaultFeatureBoost();
                _employerJobAdsCommand.CreateJobAd(jobPoster, jobAd);

                report.ProcessedJobAdIds.Add(jobAd.Id);

                // Only open those that require opening.

                if (status == JobAdStatus.Open)
                {
                    _employerJobAdsCommand.OpenJobAd(jobPoster, jobAd, false);
                }

                report.Posted++;
            }
            catch (Exception ex)
            {
                AddErrors(ex, report);
                report.Failed++;
            }
        }
示例#6
0
        private JobAd CreateJobAd(bool isHighlighted)
        {
            var employer = CreateEmployer(0);

            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <ApplicantCredit>().Id, OwnerId = employer.Id, InitialQuantity = null
            });
            _allocationsCommand.CreateAllocation(new Allocation {
                CreditId = _creditsQuery.GetCredit <JobAdCredit>().Id, OwnerId = employer.Id, InitialQuantity = null
            });

            var jobAd = employer.CreateTestJobAd(Keywords);

            jobAd.Features = isHighlighted ? JobAdFeatures.Highlight : JobAdFeatures.None;
            _employerJobAdsCommand.CreateJobAd(employer, jobAd);
            _employerJobAdsCommand.OpenJobAd(employer, jobAd, false);
            return(jobAd);
        }
 protected void OpenJobAd(IEmployer employer, JobAd jobAd)
 {
     _employerJobAdsCommand.OpenJobAd(employer, jobAd, false);
 }
示例#8
0
 public static string ReopenJobAd(Employer employer, JobAd jobAd)
 {
     _employerJobAdsCommand.OpenJobAd(employer, jobAd, true);
     return(string.Format("{0} has been reopened.", jobAd.GetTitleAndReferenceDisplayText()));
 }