public ActionResult Default(FormCollection model) { _page = PagePayload.GetCurrentContent(); Object frm = null; if (Request.Form["form_type"] != null) { string formMode = Request.Form["form_type"].ToString().ToLower(); if (formMode == "searchform") { frm = new SiteSearch(); frm = FormHelper.ParseRequest(frm, Request); this.ViewData["CMS_searchform"] = frm; if (frm != null) { this.TryValidateModel(frm); } } if (formMode == "contactform") { frm = new ContactInfo(); frm = FormHelper.ParseRequest(frm, Request); var cmt = (ContactInfo)frm; cmt.Root_ContentID = _page.ThePage.Root_ContentID; cmt.CreateDate = SiteData.CurrentSite.Now; cmt.CommenterIP = Request.ServerVariables["REMOTE_ADDR"]; this.ViewData["CMS_contactform"] = frm; if (cmt != null) { this.TryValidateModel(cmt); } } } return DefaultView(); }
public PartialViewResult Contact(ContactInfo model) { model.ReconstructSettings(); this.ViewData[ContactInfo.Key] = model; model.IsSaved = false; LoadPage(model.Settings.Uri); var settings = model.Settings; if (settings.UseValidateHuman) { bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue); if (!IsValidated) { ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText); model.ValidationValue = String.Empty; } } //TODO: log the comment and B64 encode some of the settings (TBD) if (ModelState.IsValid) { string sIP = Request.ServerVariables["REMOTE_ADDR"].ToString(); PostComment pc = new PostComment(); pc.ContentCommentID = Guid.NewGuid(); pc.Root_ContentID = _page.ThePage.Root_ContentID; pc.CreateDate = SiteData.CurrentSite.Now; pc.IsApproved = false; pc.IsSpam = false; pc.CommenterIP = sIP; pc.CommenterName = Server.HtmlEncode(model.CommenterName); pc.CommenterEmail = Server.HtmlEncode(model.CommenterEmail ?? String.Empty); pc.PostCommentText = Server.HtmlEncode(model.PostCommentText); //.Replace("<", "<").Replace(">", ">"); pc.CommenterURL = Server.HtmlEncode(model.CommenterURL ?? String.Empty); pc.Save(); model.IsSaved = true; model.CommenterName = String.Empty; model.CommenterEmail = String.Empty; model.PostCommentText = String.Empty; model.CommenterURL = String.Empty; model.ValidationValue = String.Empty; this.ViewData[ContactInfo.Key] = model; model.SendMail(pc, _page.ThePage); ModelState.Clear(); } return PartialView(settings.PostPartialName); }
public PartialViewResult Default2(ContactInfo model, bool contact) { return PartialView(); }
public HtmlHelper <ContactInfo> GetModelHelper(string partialName) { _model = InitContactInfo(partialName); return(InitHelp()); }