public ActionResult _AddContactData(int shopID, Contact model) { if (ModelState.IsValid) { try { UserActivityService.InsertShopContact(LS.CurrentUser.ID, shopID , model.ContactData, model.ContactEmail, model.ContactName , model.ContactPhone , model.DropDownItems , Request.RawUrl, Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null , LS.GetUser_IP(Request) ); model.ContactData = RP.T("Views.Shared.Contact.DropDownChooseText").ToString().ToLower() + ": " + model.ContactData; if (model.DropDownItems.Count > 0) { model.ContactData = model.ContactData + "<br />" + RP.T("Views.Shared.Contact.TextAreaPlaceholder").ToString().ToLower() + ": " + model.DropDownItems.FirstOrDefault(); } model.ContactDate = DateTime.Now; model.ContactReferal = SF.GetCookie("Referal"); model.ContactUrl = "<a target='_blank' href='" + Request.UrlReferrer.ToString() + "'>" + Request.UrlReferrer.ToString() + "</a>"; model.RoleDefault = "Member"; ShoppingService.AddContact(model); return(Redirect("/c/contact-sent")); } catch (Exception exc) { SF.LogError(exc); } } TempData["ViewData"] = ViewData; return(RedirectToAction("Contact", new { ID = shopID })); }
public ActionResult FormPage(string InvisibleCaptchaValue, FormCollection formCollection) { if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue)) { ModelState.AddModelError(string.Empty, "Captcha error."); return(Content("Error: Captcha", "text/html")); } Contact c = new Contact(); List <FormField> FormFields = CurrentPage.GetDataFromXML1 <FormField>().OrderBy(r => r.FormFieldOrder).ToList(); List <FormRool> FormRools = CurrentPage.GetDataFromXML2 <FormRool>().OrderBy(r => r.FormRoolOrder).ToList(); //get name, email and phone foreach (Uco.Models.FormField item in FormFields.OrderBy(r => r.FormFieldOrder)) { if (string.IsNullOrEmpty(Request["form_item_" + CurrentPage.ID + "_" + item.FormFieldID.ToString()])) { continue; } string t = Request["form_item_" + CurrentPage.ID + "_" + item.FormFieldID.ToString()]; if (item.FormFieldType == FormField.FormFildType.Name && string.IsNullOrEmpty(c.ContactName)) { c.ContactName = t; } else if (item.FormFieldType == FormField.FormFildType.PhoneNumber && string.IsNullOrEmpty(c.ContactPhone)) { c.ContactPhone = t; } else if (item.FormFieldType == FormField.FormFildType.EmailAddress && string.IsNullOrEmpty(c.ContactEmail)) { c.ContactEmail = t; } else { c.ContactData = c.ContactData + item.FormFieldTitle + ": " + t + "<br />"; } } string SendTo = string.Empty; //process rools foreach (Uco.Models.FormRool item in FormRools.OrderBy(r => r.FormRoolOrder)) { bool MatchingRoolAnd = true; bool MatchingRoolOr = false; bool MatchingRun = false; if (!string.IsNullOrEmpty(item.FormRoolItem1) && item.FormRoolItem1 != "null") { MatchingRun = true; FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem1.Trim()); if (field == null) { MatchingRoolAnd = false; } else { string FormRoolValue1 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()]; if (!("," + item.FormRoolValue1 + ",").Contains("," + FormRoolValue1 + ",")) { MatchingRoolAnd = false; } else if (item.FormRoolValue1 != FormRoolValue1) { MatchingRoolAnd = false; } else { MatchingRoolOr = true; } } } if (!string.IsNullOrEmpty(item.FormRoolItem2) && item.FormRoolItem2 != "null") { MatchingRun = true; FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem2.Trim()); if (field == null) { MatchingRoolAnd = false; } else { string FormRoolValue2 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()]; if (!("," + item.FormRoolValue2 + ",").Contains("," + FormRoolValue2 + ",")) { MatchingRoolAnd = false; } if (item.FormRoolValue2 != FormRoolValue2) { MatchingRoolAnd = false; } else { MatchingRoolOr = true; } } } if (!string.IsNullOrEmpty(item.FormRoolItem3) && item.FormRoolItem3 != "null") { MatchingRun = true; FormField field = FormFields.FirstOrDefault(r => r.FormFieldTitle.Trim() == item.FormRoolItem3.Trim()); if (field == null) { MatchingRoolAnd = false; } { string FormRoolValue3 = Request["form_item_" + CurrentPage.ID + "_" + field.FormFieldID.ToString()]; if (!("," + item.FormRoolValue3 + ",").Contains("," + FormRoolValue3 + ",")) { MatchingRoolAnd = false; } if (item.FormRoolValue3 != FormRoolValue3) { MatchingRoolAnd = false; } else { MatchingRoolOr = true; } } } if ((MatchingRun && item.FormRoolAnd && MatchingRoolAnd) || (MatchingRun && !item.FormRoolAnd && MatchingRoolOr)) { c.RoleDefault = item.FormRoolRole; c.Rool = item.FormRoolTitle; SendTo = item.FormRoolEmail; break; } } if (string.IsNullOrEmpty(c.RoleDefault)) { c.RoleDefault = "Admin"; } //get other data c.ContactReferal = SF.GetCookie("Referal"); c.ContactUrl = "<a target='_blank' href='http://" + Request.ServerVariables["HTTP_HOST"] + Url.Content(CurrentPage.Url) + "'>" + CurrentPage.Title + "</a>"; c.ContactDate = DateTime.Now; _db.Contacts.Add(c); _db.SaveChanges(); if (string.IsNullOrEmpty(SendTo)) { SendTo = RP.GetCurrentSettings().AdminEmail; } foreach (string item in SendTo.Split(',')) { if (!SF.isEmail(item.Trim())) { continue; } _db.OutEmails.Add(new OutEmail { MailTo = item.Trim(), Subject = Uco.Models.Resources.SystemModels.ContactMailSubject .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]), Body = Uco.Models.Resources.SystemModels.ContactMailBody .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]) .Replace("{ContactName}", c.ContactName) .Replace("{ContactEmail}", c.ContactEmail) .Replace("{ContactPhone}", c.ContactPhone) .Replace("{ContactData}", c.ContactData) .Replace("{ContactReferal}", c.ContactReferal) .Replace("{ContactUrl}", c.ContactUrl), TimesSent = 0, LastTry = DateTime.Now }); } _db.SaveChanges(); if (!string.IsNullOrEmpty(CurrentPage.Text3) && !string.IsNullOrEmpty(c.ContactEmail) && SF.isEmail(c.ContactEmail)) { _db.OutEmails.Add(new OutEmail { MailTo = c.ContactEmail.Trim(), Subject = Uco.Models.Resources.SystemModels.ContactMailSubject .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]), Body = CurrentPage.Text3 .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]) .Replace("{ContactName}", c.ContactName) .Replace("{ContactEmail}", c.ContactEmail) .Replace("{ContactPhone}", c.ContactPhone) .Replace("{ContactData}", c.ContactData) .Replace("{ContactReferal}", c.ContactReferal) .Replace("{ContactUrl}", c.ContactUrl), TimesSent = 0, LastTry = DateTime.Now }); } return(Content(((FormPage)CurrentPage).Text2, "text/html")); }
public ActionResult _FormAdd(string InvisibleCaptchaValue, int FormID) { if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue)) { ModelState.AddModelError(string.Empty, "Captcha error."); SF.LogError("_FormAdd Captcha error"); return(Content("Error: Captcha", "text/html")); } AbstractPage CurrentPage = _db.FormPages.FirstOrDefault(r => r.ID == FormID); if (CurrentPage == null) { ModelState.AddModelError(string.Empty, "CurrentPage error"); SF.LogError("_FormAdd CurrentPage error"); return(Content("Error: CurrentPage error", "text/html")); } Contact c = new Contact(); List <FormField> l = CurrentPage.GetDataFromXML1 <FormField>().OrderBy(r => r.FormFieldOrder).ToList(); foreach (Uco.Models.FormField item in l.OrderBy(r => r.FormFieldOrder)) { if (string.IsNullOrEmpty(Request["form_item_" + item.FormFieldID.ToString()])) { continue; } string t = Request["form_item_" + item.FormFieldID.ToString()]; if (item.FormFieldType == FormField.FormFildType.Name && string.IsNullOrEmpty(c.ContactName)) { c.ContactName = t; } else if (item.FormFieldType == FormField.FormFildType.PhoneNumber && string.IsNullOrEmpty(c.ContactPhone)) { c.ContactPhone = t; } else if (item.FormFieldType == FormField.FormFildType.EmailAddress && string.IsNullOrEmpty(c.ContactEmail)) { c.ContactEmail = t; } else { c.ContactData = c.ContactData + item.FormFieldTitle + ": " + t + "<br />"; } } c.ContactReferal = SF.GetCookie("Referal"); c.ContactUrl = "<a target='_blank' href='http://" + Request.ServerVariables["HTTP_HOST"] + Request.UrlReferrer.ToString() + "'>" + Request.UrlReferrer.ToString() + "</a>"; c.ContactDate = DateTime.Now; _db.Contacts.Add(c); _db.SaveChanges(); foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(',')) { if (!SF.isEmail(item.Trim())) { continue; } _db.OutEmails.Add(new OutEmail { MailTo = item.Trim(), Subject = Uco.Models.Resources.SystemModels.ContactMailSubject .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]), Body = Uco.Models.Resources.SystemModels.ContactMailBody .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]) .Replace("{ContactName}", c.ContactName) .Replace("{ContactEmail}", c.ContactEmail) .Replace("{ContactPhone}", c.ContactPhone) .Replace("{ContactData}", c.ContactData) .Replace("{ContactReferal}", c.ContactReferal) .Replace("{ContactUrl}", c.ContactUrl), TimesSent = 0, LastTry = DateTime.Now }); } _db.SaveChanges(); return(Content(RP.GetTextComponent("_FormAdd"), "text/html")); }
public ActionResult _SmallFormAdd(ContactSmallForm csf, string InvisibleCaptchaValue) { if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue)) { ModelState.AddModelError(string.Empty, "Captcha error."); SF.LogError("_SmallFormAdd Captcha error"); return(Content("Error: Captcha", "text/html")); } if (ModelState.IsValid) { Contact c = new Contact(); c.ContactEmail = csf.ContactEmail; c.ContactName = csf.ContactName; c.ContactPhone = csf.ContactPhone; c.ContactReferal = SF.GetCookie("Referal"); string UrlReferrer = UcoString.GetUtf8String(Request.UrlReferrer.ToString()); c.ContactUrl = "<a target='_blank' href='" + UrlReferrer + "'>" + UrlReferrer + "</a>"; c.ContactDate = DateTime.Now; _db.Contacts.Add(c); _db.SaveChanges(); foreach (string item in RP.GetCurrentSettings().AdminEmail.Split(',')) { if (!SF.isEmail(item.Trim())) { continue; } _db.OutEmails.Add(new OutEmail { MailTo = item.Trim(), Subject = Uco.Models.Resources.SystemModels.ContactMailSubject .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]), Body = Uco.Models.Resources.SystemModels.ContactMailBody .Replace("{ID}", c.ID.ToString()) .Replace("{HTTP_HOST}", Request.ServerVariables["HTTP_HOST"]) .Replace("{ContactName}", c.ContactName) .Replace("{ContactEmail}", c.ContactEmail) .Replace("{ContactPhone}", c.ContactPhone) .Replace("{ContactData}", c.ContactData) .Replace("{ContactReferal}", c.ContactReferal) .Replace("{ContactUrl}", c.ContactUrl), TimesSent = 0, LastTry = DateTime.Now }); } _db.SaveChanges(); return(Content(RP.GetTextComponent("_SmallFormAdd"), "text/html")); } else { SF.LogError("_SmallFormAdd Model not valid"); return(Content("Error: Model not valid", "text/html")); } }