Example #1
0
        public async Task <ActionResult> GetInvolvedSubmission(GetInvolvedViewModel getInvolved)
        {
            ViewBag.ModelState = ModelState;
            if (ModelState.IsValid)
            {
                var placeholders = new Dictionary <string, dynamic> {
                    { "Name", FormFieldSanitizer.SanitizeFormField(getInvolved.Name) },
                    { "Email", getInvolved.Email },
                };

                try
                {
                    await _emailSender.SendGetInvolvedEmailAsync(ConfigurationManager.AppSettings["SRMEmailAddress"], placeholders);
                }
                catch (HttpRequestValidationException exc)
                {
                    var enableAITelemetry = WebConfigurationManager.AppSettings["EnableAITelemetry"];

                    if (enableAITelemetry != null && bool.Parse(enableAITelemetry))
                    {
                        var ai = new TelemetryClient();
                        ai.TrackException(exc);
                        ai.TrackTrace($"Get involved email rejected due to SQL injection attack!");
                        ai.TrackTrace($"Contact us email sending failed for: {getInvolved.Name} - ({getInvolved.Email})");
                    }
                    throw exc;
                }
                catch (Exception exception)
                {
                    var enableAITelemetry = WebConfigurationManager.AppSettings["EnableAITelemetry"];

                    if (enableAITelemetry != null && bool.Parse(enableAITelemetry))
                    {
                        var ai = new TelemetryClient();
                        ai.TrackException(exception);
                        ai.TrackTrace($"Get involved email sending error: {exception.Message}");
                        ai.TrackTrace($"Get involved email sending failed for: {getInvolved.Name} ({getInvolved.Email})");
                    }
                    throw;
                }

                SetRecruitmentBannerCookie();
                return(View("GetInvolvedConfirmation"));
            }
            else
            {
                return(View("GetInvolved", getInvolved));
            }
        }