protected void Page_Load(object sender, EventArgs e)
        {
            string formType          = Request["formType"];
            string businessArea      = Request["businessArea"];
            string endingDateValue   = Request["endDate"];
            string startingDateValue = Request["startDate"];
            string contactType       = Request["contactType"];
            string format            = Request["format"];
            string columnList        = Request["columnList"];
            string columnOrderList   = Request["columnOrderList"];
            string columnMap         = Request["columnMap"];

            if (string.IsNullOrEmpty(formType) && string.IsNullOrEmpty(businessArea))
            {
                wf_Status.Text    = "No form type provided.";
                wf_Status.Visible = true;
            }
            else
            {
                var service = new ContactFormService();
                if (string.IsNullOrEmpty(columnMap))
                {
                    service.WriteContactListFileToResponse(formType, businessArea, endingDateValue, startingDateValue, contactType, format, columnList, columnOrderList, Response);
                }
                else
                {
                    service.WriteContactListFileToResponseColumnMap(formType, businessArea, endingDateValue, startingDateValue, contactType, format, columnMap, Response);
                }
                Response.End();
            }
        }
Beispiel #2
0
 public ContactController(
     ContactFormService formService,
     IStringLocalizer <SimpleContactFormStringResources> localizer,
     ILogger <ContactController> logger
     )
 {
     sr  = localizer;
     log = logger;
     this.formService = formService;
 }
Beispiel #3
0
        public ContactResult FunctionHandler(ContactModel contact, ILambdaContext context)
        {
            var settings = GetSettings();

            settings.RecaptchaSettings.RecaptchaResponse = contact.RecaptchaResponse;

            var contactService = new ContactFormService(new LoggerAdapter(context.Logger));

            return(contactService.Submit(contact, settings));
        }
Beispiel #4
0
        public async Task MarkAsAnsweredShouldNotMarkNotExistingEmailId(int emailId)
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var contactFormRepository = new EfRepository <ContactFormEntry>(context);
            var contactFormService    = new ContactFormService(contactFormRepository);

            await contactFormService.MarkAsAnsweredAsync(emailId);

            var result = await contactFormService.MarkAsAnsweredAsync(emailId);

            Assert.False(result);
        }
Beispiel #5
0
        public async Task MarkAsAnsweredShouldMarkCorrectlyNotAnsweredEmailId()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var contactFormRepository = new EfRepository <ContactFormEntry>(context);
            var contactFormService    = new ContactFormService(contactFormRepository);

            var newEmailId = await this.GetNewEmailId(contactFormService, contactFormRepository);

            var result = await contactFormService.MarkAsAnsweredAsync(newEmailId);

            Assert.True(result);
        }
Beispiel #6
0
        public async Task AddAsyncShouldAddContactFormEntryCorrectly()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var contactFormRepository = new EfRepository <ContactFormEntry>(context);
            var contactFormService    = new ContactFormService(contactFormRepository);

            var input = new ContactFormViewModel();

            var result = await contactFormService.AddAsync(input);

            Assert.True(result);
        }
Beispiel #7
0
        public async Task AddAsyncShouldIncreaseContactFormEntries()
        {
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();
            var contactFormRepository = new EfRepository <ContactFormEntry>(context);
            var contactFormService    = new ContactFormService(contactFormRepository);

            var input       = new ContactFormViewModel();
            var countPreAdd = contactFormRepository.All().Count();
            var result      = await contactFormService.AddAsync(input);

            var countAfterAdd = contactFormRepository.All().Count();

            Assert.AreEqual(countPreAdd + 1, countAfterAdd);
        }
 public ContactController(
     ContactFormService formService,
     IPrePopulateContactForm formPopulator,
     IRecaptchaServerSideValidator recaptchServerSideValidator,
     IStringLocalizer <SimpleContactFormStringResources> localizer,
     ILogger <ContactController> logger
     )
 {
     StringLocalizer             = localizer;
     Log                         = logger;
     FormPopulator               = formPopulator;
     FormService                 = formService;
     RecaptchServerSideValidator = recaptchServerSideValidator;
 }
Beispiel #9
0
        public async Task <IActionResult> SendMessage(ContactForm form, [FromServices] ContactFormService contactFormService)
        {
            if (form != null && ModelState.IsValid)
            {
                var status = await contactFormService.SendContactMessage(form);

                Thread.Sleep(Constants.Timers.Spinner);

                if (status)
                {
                    return(PartialView("_ContactForm"));
                }
            }

            return(null);
        }
Beispiel #10
0
    private void ExportResults(string format)
    {
        var service = new ContactFormService();

        // Write the file. . .
        var success = service.WriteContactListFileToResponse(GetValidFormType(wf_FormTypes.SelectedValue), GetValidBusinessArea(wf_BusinessTypes.SelectedValue), wf_EndingOn.Text, wf_StartingFrom.Text, null, format, Response);

        if (!success)
        {
            wf_Status.Visible = true;
            wf_Status.Text    = "The was an error processing your export.";
        }
        else
        {
            wf_Status.Visible = false;
        }

        Response.End();
    }
Beispiel #11
0
 public CoreWidgetApiController
 (
     HtmlDbContext htmlDbContext,
     AlertService alertService,
     TitleService titleService,
     RawHtmlService rawHtmlService,
     ImageService imageService,
     IconService iconService,
     HeroService heroService,
     LightboxService lightboxService,
     ContactFormService contactFormService
 )
 {
     _htmlDbContext      = htmlDbContext;
     _alertService       = alertService;
     _titleService       = titleService;
     _rawHtmlService     = rawHtmlService;
     _imageService       = imageService;
     _iconService        = iconService;
     _heroService        = heroService;
     _lightboxService    = lightboxService;
     _contactFormService = contactFormService;
 }
        public IComponent GetComponent(IPublishedContent componentContent, IPublishedContent pageContent)
        {
            var documentTypeAlias = componentContent.DocumentTypeAlias;

            switch (documentTypeAlias)
            {
            case DocumentTypeAliases.Banner:
                var bannerService = new BannerService();
                return(bannerService.GetViewModel(componentContent));

            case DocumentTypeAliases.InformationWithoutBackground:
                var informationWithoutBackgroundService = new InformationWithoutBackgroundService();
                return(informationWithoutBackgroundService.GetViewModel(componentContent));

            case DocumentTypeAliases.InformationWithoutBackgroundVertical:
                var informationWithBackgroundVerticalService = new InformationWithoutBackgroundVerticalService();
                return(informationWithBackgroundVerticalService.GetViewModel(componentContent));

            case DocumentTypeAliases.InformationWithBackground:
                var informationWithBackgroundService = new InformationWithBackgroundService();
                return(informationWithBackgroundService.GetViewModel(componentContent));

            case DocumentTypeAliases.ContactForm:
                var contactFormService = new ContactFormService();
                return(contactFormService.GetViewModel(componentContent));

            case DocumentTypeAliases.ContactDetails:
                var contactDetailsService = new ContactDetailsService();
                return(contactDetailsService.GetViewModel(componentContent));

            case DocumentTypeAliases.Footer:
                var footerService = new FooterService();
                return(footerService.GetViewModel(componentContent));
            }

            return(null);
        }
Beispiel #13
0
        protected void bSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                XmlDocument xml = new XmlDocument();
                XmlNode     rootNode;
                XmlNode     node;
                string      surveyName = "";
                ContactForm contact    = new ContactForm();

                rootNode = xml.CreateElement("root");
                xml.AppendChild(rootNode);

                foreach (string key in Request.Form)
                {
                    string value = Request[key];

                    if (key.StartsWith(ControlClientID) && key != ControlClientID + "$" + bSubmit.ID)
                    {
                        if (key == ControlClientID + "$" + _surveyNameFieldName)
                        {
                            surveyName = value;
                        }
                        else
                        {
                            node           = xml.CreateElement(key.Replace(ControlClientID + "$", ""));
                            node.InnerText = value;

                            if (FieldMappings != null && FieldMappings.ContainsKey(key))
                            {
                                switch (FieldMappings[key])
                                {
                                case ContactFields.Name:
                                    contact.Name = (contact.Name + NAME_DELIMITER + value).TrimStart(' ');
                                    break;

                                case ContactFields.Company:
                                    contact.Company = value;
                                    break;

                                case ContactFields.Zip:
                                    contact.Zip = value;
                                    break;

                                case ContactFields.Phone:
                                    contact.Phone = value;
                                    break;

                                case ContactFields.Email:
                                    contact.Email = value;
                                    break;
                                }
                            }

                            rootNode.AppendChild(node);
                        }
                    }
                }

                OwensCorning.SurveyService.Data.SurveyForm form =
                    new OwensCorning.SurveyService.Data.SurveyForm()
                {
                    FormName = surveyName,
                    FormData = XElement.Load(xml.CreateNavigator().ReadSubtree())
                };

                using (SurveyClient client = new SurveyClient())
                {
                    client.SaveSurvey(form);
                }

                try
                {
                    //Horrible, needs to be fixed ASAP
                    string[] names = contact.Name.Split(NAME_DELIMITER);
                    ExactTargetService.Instance.Register(
                        new ExactTargetUser()
                    {
                        FirstName = names[0],
                        LastName  = names[1],
                        Company   = contact.Company,
                        Business  = string.Empty,    //EMBED THIS IN XML
                        Email     = contact.Email,
                        Phone     = contact.Phone
                                    //INTERESTS?
                    }
                        );
                }
                catch (Exception ex)
                {
                    log.Error("Failed saving survey to ExactTarget: " + ex.Message, ex);
                }

                try
                {
                    contact.FormData = form.FormData.ToString();
                    ContactFormService.PublishContactForm(contact);
                }
                catch (Exception ex)
                {
                    log.Error("Failed publishing survey to contact form web service: " + ex.Message, ex);
                }

                pForm.Visible     = false;
                pThankYou.Visible = true;
            }
        }
 public ContactController(ContactFormService contactFormService, IOptions <ContactSettings> contactSettings)
 {
     this.contactFormService = contactFormService;
     this.contactSettings    = contactSettings.Value;
 }
Beispiel #15
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "options", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            ContactModel contact;
            var          isJson = req.ContentType.StartsWith("application/json");

            if (isJson)
            {
                string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
                contact = JsonConvert.DeserializeObject <ContactModel>(requestBody);
            }
            else
            {
                contact = new ContactModel
                {
                    ContactName       = req.Form["ContactName"],
                    Email             = req.Form["Email"],
                    Phone             = req.Form["Phone"],
                    Subject           = req.Form["Subject"],
                    Category          = req.Form["Category"],
                    Message           = req.Form["Message"],
                    RecaptchaResponse = req.Form["g-recaptcha-response"]
                };
            }

            if (contact == null)
            {
                return(new BadRequestObjectResult("Please pass a contact form data"));
            }
            else
            {
                // Get settings
                var config = new ConfigurationBuilder()
                             .SetBasePath(context.FunctionAppDirectory)
                             .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                             .AddEnvironmentVariables()
                             .Build();
                var contactSettings = new ContactSettings();
                config.GetSection("ContactSettings").Bind(contactSettings);

                var contactService = new ContactFormService(log);
                contactSettings.RecaptchaSettings.RecaptchaResponse = contact.RecaptchaResponse;
                var result = contactService.Submit(contact, contactSettings);

                if (isJson)
                {
                    return((ActionResult) new OkObjectResult(result));
                }
                else
                {
                    // Return 'text/html'
                    if (!string.IsNullOrEmpty(contactSettings.PostSettings.RedirectURL) && contactSettings.PostSettings.RedirectSeconds == -1)
                    {
                        return(new RedirectResult(string.Format(contactSettings.PostSettings.RedirectURL, result.Success ? "1" : "0")));
                    }
                    else
                    {
                        return new ContentResult {
                                   Content = contactService.GetResultHTML(result, contactSettings), ContentType = "text/html", StatusCode = 200
                        }
                    };
                }
            }
        }
    }
 public ContactFormSettings(ContactFormService contactFormService)
 {
     _contactFormService = contactFormService;
 }