예제 #1
0
 /// <summary>
 /// Create a new tbl_Form object.
 /// </summary>
 /// <param name="formID">Initial value of the FormID property.</param>
 /// <param name="f_Name">Initial value of the F_Name property.</param>
 /// <param name="f_DomainID">Initial value of the F_DomainID property.</param>
 /// <param name="f_Deleted">Initial value of the F_Deleted property.</param>
 /// <param name="f_Captcha">Initial value of the F_Captcha property.</param>
 public static tbl_Form Createtbl_Form(global::System.Int32 formID, global::System.String f_Name, global::System.Int32 f_DomainID, global::System.Boolean f_Deleted, global::System.Boolean f_Captcha)
 {
     tbl_Form tbl_Form = new tbl_Form();
     tbl_Form.FormID = formID;
     tbl_Form.F_Name = f_Name;
     tbl_Form.F_DomainID = f_DomainID;
     tbl_Form.F_Deleted = f_Deleted;
     tbl_Form.F_Captcha = f_Captcha;
     return tbl_Form;
 }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tbl_Form EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotbl_Form(tbl_Form tbl_Form)
 {
     base.AddObject("tbl_Form", tbl_Form);
 }
예제 #3
0
        public ActionResult SaveFormSubmission(FormCollection values)
        {
            string submittedFormID = values["FormID"];
            bool redirect = false;
            string url = "";

            tbl_Form form = new tbl_Form();

            int FormID;
            if (Int32.TryParse(submittedFormID, out FormID))
            {
                form = WebPagesService.GetFormByID(FormID);
            }

            if (form.F_Captcha)
            {
                RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper(DomainService.GetSettingsValue(SettingsKey.recaptcha_private_key));
                if (String.IsNullOrEmpty(recaptchaHelper.Response))
                {
                    return Json(new { error = "Captcha answer cannot be empty.", formID = submittedFormID }, "text/html");
                }

                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    return Json(new { error = "Incorrect captcha answer.", formID = submittedFormID }, "text/html");
                }
            }
            if (ModelState.IsValid)
            {
                string recipients = this.Domain != null ? this.Domain.DO_Email : String.Empty;
                if (!string.IsNullOrEmpty(values["RecipientEmail"]) && values["RecipientEmail"].Contains("@"))
                {
                    recipients = values["RecipientEmail"];
                }
                if (!string.IsNullOrEmpty(values["subscribe"]) && this.Domain.IsAnyCRMEnabled)
                {
                    var customerEmail = values.AllKeys.FirstOrDefault(m => m != "RecipientEmail" && (m.Contains("email") || m.Contains("Email")));
                    if (!string.IsNullOrEmpty(customerEmail))
                        UserService.SubscribeNewsletter(values[customerEmail], true, this.DomainID);
                    else
                    {
                        var customer = UserService.GetCustomerByID(this.AdminUser.UserID);
                        if (customer != null)
                            UserService.SubscribeNewsletter(customer.CU_Email, true, this.DomainID);
                    }
                }
                MailingService.SendCustomForm(WebPagesService.SaveFormSubmission(values, recipients, DateTime.UtcNow,
                    Convert.ToInt32(submittedFormID)), recipients);

                if (form.tbl_SiteMap != null)
                {
                    //SiteMapType type = (SiteMapType)form.tbl_SiteMap.SM_TypeID;
                    url = String.Format("/{0}", form.tbl_SiteMap.SM_URL.Trim('/'));
                    redirect = true;
                }

                return Json(new { success = true, formID = submittedFormID, redirect = redirect, url = url }, "text/html");
            }
            return Json(new { success = false, formID = submittedFormID }, "text/html");
        }