Beispiel #1
0
        private JobAd CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster,
                                     bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2,
                                     string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle,
                                     JobTypes jobtypes, bool isResidenacyRequired, string externalRef, string maxsalary,
                                     string minsalary, string package, IList <Industry> reqIndustries, string companyname,
                                     LocationReference jobLocation, DateTime expiryDate)
        {
            var salary       = SalaryExtensions.Parse(minsalary, maxsalary, SalaryRate.Year, true);
            var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 };

            var newJobAd = new JobAd
            {
                Status     = adStatus,
                PosterId   = adPoster.Id,
                Visibility =
                {
                    HideContactDetails = adHideContactDetails,
                    HideCompany        = false,
                },
                ContactDetails = adContactDetails,
                Title          = adTitle,
                Integration    = { ExternalReferenceId = externalRef },
                LogoId         = logoImg == null ? (Guid?)null : logoImg.Id,
                ExpiryTime     = expiryDate,
                Description    =
                {
                    CompanyName       = companyname,
                    Content           = adContent,
                    PositionTitle     = positionTitle,
                    ResidencyRequired = isResidenacyRequired,
                    JobTypes          = jobtypes,
                    Industries        = reqIndustries,
                    Summary           = summary,
                    Salary            = salary,
                    Package           = package,
                    BulletPoints      = bulletPoints,
                    Location          = jobLocation,
                }
            };

            _jobAdsCommand.CreateJobAd(newJobAd);
            _jobAdsCommand.OpenJobAd(newJobAd);

            return(newJobAd);
        }
Beispiel #2
0
        public AjaxResult SaveDesiredJobDetails(string desiredJobTitle,
                                                string desiredSalaryLower, string desiredSalaryUpper,
                                                string desiredSalaryLabel, int desiredJobTypes,
                                                string desiredJobTypesLabel, bool emailSuggestedJobs,
                                                string desiredLocalitiesLabel,
                                                string relocationChoiceLabel,
                                                string relPref,
                                                string selectedLocalities)
        {
            var errorMessages = new List <string>();

            RelocationPreference relocationPreference = RelocationPreference.No;

            try
            {
                relocationPreference = (RelocationPreference)Enum.Parse(typeof(RelocationPreference), relPref);
            }
            catch (ArgumentException)
            {
                errorMessages.Add(NoRelocationPreferenceSpecified);
            }

            if (errorMessages.Count != 0)
            {
                return(new AjaxResult(AjaxResultCode.FAILURE, ConvertMessagesToString(errorMessages)));
            }

            try
            {
                EnsureMemberLoggedIn();

                var member         = LoggedInMember;
                var localitiesText = String.Empty;

                var candidate     = _candidatesCommand.GetCandidate(member.Id);
                var desiredSalary = SalaryExtensions.Parse(desiredSalaryLower, desiredSalaryUpper, SalaryRate.Year, true);

                // Update.

                candidate.DesiredJobTitle      = desiredJobTitle;
                candidate.DesiredJobTypes      = (JobTypes)desiredJobTypes;
                candidate.DesiredSalary        = desiredSalary;
                candidate.RelocationPreference = relocationPreference;
                candidate.RelocationLocations  = WillingnessToRelocate.GetSelectedLocations(candidate, selectedLocalities);
                _candidatesCommand.UpdateCandidate(candidate);

                if (candidate.RelocationPreference != RelocationPreference.No)
                {
                    localitiesText = TextUtil.TruncateForDisplay(candidate.GetRelocationsDisplayText(), DesiredJob.MaxRelocationLocalitiesLength);
                }

                var relocationPreferenceText = DesiredJob.GetRelocationPreference(candidate.RelocationPreference);

                UpdateSuggestedJobs(member.Id, emailSuggestedJobs);

                var userData = new ElementValuesUserData(
                    new[]
                {
                    desiredSalaryLabel,
                    desiredJobTypesLabel,
                    desiredLocalitiesLabel,
                    relocationChoiceLabel
                },
                    new[]
                {
                    candidate.DesiredSalary == null ? string.Empty : candidate.DesiredSalary.GetDisplayText(),
                    candidate.DesiredJobTypes.GetDesiredClauseDisplayText(),
                    localitiesText, relocationPreferenceText
                });

                return(new AjaxResult(AjaxResultCode.SUCCESS, null, userData));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }