//[OutputCache(Duration = 60)]
        public ActionResult Index()
        {
            string        conString  = "Data Source=VKT-TAYLANA\\SQLEXPRESS;Initial Catalog=BlogWebSystem;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            SqlConnection connection = new SqlConnection(conString);

            if (connection.State == ConnectionState.Closed)
            {
                connection.Open();
            }

            string        contactMessage = "Select * From Contact";
            SqlCommand    contactCommand = new SqlCommand(contactMessage, connection);
            SqlDataReader reader         = contactCommand.ExecuteReader();

            List <Models.ContactModel> contactModel = new List <Models.ContactModel>();

            Models.ContactModel item;
            while (reader.Read())
            {
                item                = new Models.ContactModel();
                item.Id             = Convert.ToInt32(reader["Id"]);
                item.ContactName    = reader["Name"].ToString();
                item.ContactMail    = reader["Email"].ToString();
                item.ContactMessage = reader["Message"].ToString();
                item.ContactDate    = reader["Date"].ToString();
                contactModel.Add(item);
            }

            connection.Close();
            reader.Close();
            return(View(contactModel));
        }
        //stops posting from the form unless within the site

        public ActionResult submitForm(Models.ContactModel model)
        {
            //check model is valid when submitted
            if (ModelState.IsValid)
            {
                SendEmail(model);
                return(RedirectToCurrentUmbracoPage());
            }
            return(CurrentUmbracoPage());
        }
        private void SendEmail(Models.ContactModel model)
        {
            //send as from user email to user email address
            MailMessage message = new MailMessage(model.EmailAddress, model.EmailAddress);

            //using model values to create email
            message.Subject = string.Format("Enquiry from {0} {1} - Email: {2}", model.FirstName, model.LastName, model.EmailAddress);
            message.Body    = model.Message;

            //used to send email
            SmtpClient client = new SmtpClient("127.0.0.1", 25);

            client.Send(message);
        }
Beispiel #4
0
 public ActionResult ContactUs(Models.ContactModel model, bool captchaValid, string captchaErrorMessage)
 {
     if (captchaValid)
     {
         if (model.firstname != null && model.lastname != null && model.email != null && model.message != null)
         {
             Manager.EmailManager.SentContactEmail(model);
             return(RedirectToAction("Confirmation", "Home"));
         }
     }
     else
     {
         ModelState.AddModelError("recaptcha", captchaErrorMessage);
     }
     return(View(model));
 }
Beispiel #5
0
        public IActionResult SaveContact(IFormCollection form)
        {
            var contactModel = new Models.ContactModel
            {
                Name    = HttpUtility.HtmlEncode(form["contact-name"]),
                Email   = form["contact-email"],// accepting raw email address
                Message = HttpUtility.HtmlEncode(form["contact-message"]),
            };

            // TODO: spam protection (recaptcha?)

            var successful = SlickCMS.Web.Global.SendEmail(contactModel);

            // working with Session in .NET Core https://benjii.me/2016/07/using-sessions-and-httpcontext-in-aspnetcore-and-mvc-core/
            HttpContext.Session.SetString("ContactFormResult", (successful ? "success" : "error"));

            return(Redirect("/contact"));
        }
Beispiel #6
0
        public static void SentContactEmail(Models.ContactModel contactInfo)
        {
            using (var client = new SmtpClient())
            {
                using (var message = new MailMessage(new MailAddress(EmailFrom, "Computech Corporation"), new MailAddress(EmailTo, "Al Fields")))
                {
                    message.Subject = "Computech Job Search Contact Request";
                    message.Body    = "<html><head><meta content=\"text/html; charset=utf-8\" /></head><body><p>Hello Al, " +
                                      "</p><p>My name is " + contactInfo.firstname + " " + contactInfo.lastname + ".</p>"
                                      + "<p> My email address is " + contactInfo.email + ".  Here is my contact message:"
                                      + "</p><p>" + contactInfo.message + "</p><div>Best regards,</div><div>" + contactInfo.firstname + "</div><p>Do not forward " +
                                      "this email.</p></body></html>";
                    message.IsBodyHtml = true;

                    client.EnableSsl = true;
                    client.Send(message);
                };
            };
        }
Beispiel #7
0
        public ActionResult Index(QuoteViewModel vm)
        {
            try
            {
                //if coverage supplied, limit coverage to max of 1,000,000 based on age
                decimal maxCoverage = 0M;
                maxCoverage = QuoteViewModel.GetMaxCoverageBasedOnAge(vm.Age);

                vm.CoverageAmount = vm.CoverageAmount > maxCoverage ? maxCoverage : vm.CoverageAmount; //update coverage based on max

                /*
                 * //override coverage based on health and smoker status
                 * if ((vm.health == "OLI_UNWRITE_RATED" || vm.health == "OLI_UNWRITE_POOR") && vm.tobacco == "OLI_TOBACCO_CURRENT")
                 *  vm.CoverageAmount = 750000M;
                 */

                //override coverage based on risk class
                if (vm.Age < 56 && vm.CoverageAmount < 525000M && (vm.riskClass.TC == (int)QuoteViewModel.RiskClasses.RATED_TOBACCO ||
                                                                   vm.riskClass.TC == (int)QuoteViewModel.RiskClasses.RATED2_NONTOBACCO ||
                                                                   vm.riskClass.TC == (int)QuoteViewModel.RiskClasses.RATED2_TOBACCO))
                {
                    vm.CoverageAmount = 525000M;
                }

                // Determine eligibility
                EligibilityInfo eligibility = BusinessRulesClass.IsEligible(vm.Age, vm.stateInfo.Name, vm.tobacco, vm.health, null == vm.ReplacementPolicy ? false : vm.ReplacementPolicy.Value);

                // If eligible build XML and send to firelight
                if (eligibility.IsEligible)
                {
                    // Build XMLs
                    var client  = new NewBusinessService.NewBusinessClient("CustomBinding_NewBusiness");
                    var addrUri = client.Endpoint.Address.Uri;
                    var newUri  = String.Format(addrUri.ToString(), Session["GCId"] ?? "");

                    var newAddress = new System.ServiceModel.EndpointAddress(newUri);
                    client.Endpoint.Address = newAddress;

                    var txLife = Create103(vm);
                    NewBusinessService.TXLife response = client.SubmitNewBusinessApplication(txLife);

                    var code = response.TXLifeResponse[0].TransResult.ResultCode.Value; //response code??
                    if (code == "RESULT_SUCCESS")
                    {
                        //redirect to url
#if DEBUG
                        string url = String.Format("https://staging.firelighteapp.com/egapp/PassiveCall.aspx?O=3138&C=D2C&refid={0}", response.TXLifeResponse[0].TransRefGUID ?? String.Empty, Session["GCId"] ?? String.Empty);
#else
                        string url = String.Format("https://www.firelighteapp.com/EGApp/PassiveCall.aspx?O=3138&C=D2C&refid={0}&GAT=UA-97044577-1&GAC={1}", response.TXLifeResponse[0].TransRefGUID ?? String.Empty, Session["GCId"] ?? String.Empty);
#endif
                        return(Redirect(url));
                    }

                    else
                    {
                        //failed
                        var msg = response.TXLifeResponse[0].TransResult.ResultInfo[0].ResultInfoDesc;
                        vm.ViewMessages.Add("Web Service Returned a Failure Code: " + msg);
                        return(View(vm));
                    }
                }
                else
                {
                    TempData["ContactViewModel"] = new Models.ContactModel {
                        denialMessage = eligibility.EligibilityMessage, isReplacementReject = eligibility.IsReplacememtReject, state = eligibility.State
                    };
                    return(RedirectToActionPermanent("Contact", "Contact"));
                }
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;
                var msg = "There was an error connecting to the application portal.";
                vm.ViewMessages.Add(msg);
                return(View(vm));
            }
        }