示例#1
0
        protected void AdsRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var jobAdId = new Guid((string)e.CommandArgument);
            var jobAd   = _jobAdsQuery.GetJobAd <JobAd>(jobAdId);

            if (jobAd == null)
            {
                throw new ArgumentException("No job ad with ID " + jobAdId + " was found.");
            }

            string message;

            switch (e.CommandName)
            {
            case OpenAdCommand:
                if (_jobAdsCommand.CanBeOpened(jobAd))
                {
                    message = JobAdFacade.ReopenJobAd(LoggedInEmployer, jobAd);
                    OnJobAdRemoved(e.Item.ItemIndex, message);
                }
                else
                {
                    // Reposting - simply redirect to the Purchase Preview page and take the reposting workflow from there.

                    message = "Please review the ad before publishing it.";
                    var quantity = _employerCreditsQuery.GetEffectiveActiveAllocation <JobAdCredit>(LoggedInEmployer).RemainingQuantity;
                    if (quantity != null && quantity > 0)
                    {
                        message = "Reposting this ad will use one credit. " + message;
                    }

                    var previewUrl = JobAdsRoutes.Preview.GenerateUrl(new { jobAdId = jobAd.Id });
                    RedirectWithNotification(previewUrl, NotificationType.Information, message);
                }
                break;

            case CloseAdCommand:
                message = CloseJobAd(jobAd);
                OnJobAdRemoved(e.Item.ItemIndex, message);
                break;

            case DeleteDraftCommand:
                message = DeleteDraftAd(jobAd);
                OnJobAdRemoved(e.Item.ItemIndex, message);
                break;

            default:
                throw new ApplicationException("Unexpected command");
            }
        }
示例#2
0
        private PreviewJobAdModel GetPreviewJobAdModel(IUser employer, JobAd jobAd, JobAdFeaturePack featurePack)
        {
            var canBeOpened = _jobAdsCommand.CanBeOpened(jobAd);
            var expiryTime  = canBeOpened ? GetExpiryTime(jobAd.ExpiryTime, jobAd.Features) : GetExpiryTime(null, jobAd.Features);

            // For the purposes of previewing the job ad treat it as if it is open no matter what its real status is.

            var status = jobAd.Status;

            jobAd.Status = JobAdStatus.Open;

            // Preview the job ad as an anonymous member.

            var view = _memberJobAdViewsQuery.GetMemberJobAdView(null, jobAd);

            return(new PreviewJobAdModel
            {
                JobAd = view,
                JobAdCredits = GetJobAdCredits(employer),
                Status = status,
                ExpiryTime = expiryTime,
                CanBeOpened = canBeOpened,
                JobPoster = employer,
                FeaturePack = featurePack,
                Features = GetFeatures(),
                OrganisationCssFile = employer is IEmployer?HttpContext.GetOrganisationJobAdCssFile(((IEmployer)employer).Organisation.Id) : null,
            });
        }