public ActionResult CreateAlert(JobAlert alert)
        {
            var query = HttpUtility.ParseQueryString(Request.Url.Query);

            if (ModelState.IsValid)
            {
                var converter  = new JobSearchQueryConverter(ConfigurationManager.AppSettings["TranslateObsoleteJobTypes"]?.ToUpperInvariant() == "TRUE");
                var encoder    = new JobAlertIdEncoder(converter);
                var alertsRepo = new AzureTableStorageAlertsRepository(converter, ConfigurationManager.ConnectionStrings["Escc.EastSussexGovUK.Umbraco.AzureStorage"].ConnectionString);
                alert.Query   = converter.ToQuery(query);
                alert.AlertId = encoder.GenerateId(alert);
                alertsRepo.SaveAlert(alert);

                var jobAlertsSettings = new JobAlertsSettingsFromUmbraco(Umbraco).GetJobAlertsSettings(alert.JobsSet);
                if (jobAlertsSettings != null && !String.IsNullOrEmpty(jobAlertsSettings.NewAlertEmailSubject))
                {
                    var emailService = ServiceContainer.LoadService <IEmailSender>(new ConfigurationServiceRegistry(), new HttpContextCacheStrategy());
                    var sender       = new JobAlertsByEmailSender(jobAlertsSettings, new HtmlJobAlertFormatter(jobAlertsSettings, encoder), emailService);

                    sender.SendNewAlertConfirmation(alert);
                }

                query.Add("subscribed", "1");
            }
            return(new RedirectToUmbracoPageResult(CurrentPage, query));
        }
Esempio n. 2
0
        public void ObsoleteJobTypeIsTranslated()
        {
            var collection = new NameValueCollection();

            collection["jobtypes"] = "Personnel and HR";
            var converter = new JobSearchQueryConverter(true);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Human Resources", query.JobTypes[0]);
        }
Esempio n. 3
0
        public void JobTypeIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["jobtypes"] = "Example job type";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Example job type", query.JobTypes[0]);
        }
Esempio n. 4
0
        public void ReferenceIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["ref"] = "ABC1234";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("ABC1234", query.JobReference);
        }
Esempio n. 5
0
        public void WorkingPatternIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["workpatterns"] = "Working pattern";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Working pattern", query.WorkPatterns[0]);
        }
Esempio n. 6
0
        public void ContractTypeIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["contracttypes"] = "Contract type";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Contract type", query.ContractTypes[0]);
        }
Esempio n. 7
0
        public void PayGradeIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["paygrades"] = "Single Status";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Single Status", query.PayGrades[0]);
        }
Esempio n. 8
0
        public void SalaryRangeIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["salaryranges"] = "£10000 to £20000";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("£10,000 to £20,000", query.SalaryRanges[0]);
        }
Esempio n. 9
0
        public void OrganisationIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["org"] = "Example organisation";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Example organisation", query.Organisations[0]);
        }
Esempio n. 10
0
        public void KeywordsArePopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["keywords"] = "this is a test";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("this is a test", query.Keywords);
        }
Esempio n. 11
0
        public void DepartmentIsPopulatedFromCollection()
        {
            var collection = new NameValueCollection();

            collection["department"] = "Example department";
            var converter = new JobSearchQueryConverter(false);

            var query = converter.ToQuery(collection);

            Assert.AreEqual("Example department", query.Departments[0]);
        }