Ejemplo n.º 1
0
        public string Parse(HtmlHelper htmlHelper, string current)
        {
            if (current == null)
            {
                return(null);
            }

            bool submitted = true.Equals(htmlHelper.ViewContext.TempData["form-submitted"]);
            var  errors    = htmlHelper.ViewContext.TempData["form-submitted-message"] as List <string>;
            var  data      = htmlHelper.ViewContext.TempData["form-data"] as NameValueCollection;
            var  status    = new FormSubmittedStatus(submitted, errors, data);

            current = OtherPageFormMatch.Replace(current,
                                                 match =>
            {
                int pageId = Convert.ToInt32(
                    match.Value.Replace("[", "").Replace("]", "").Split('-')[1]);
                var document = _documentService.GetDocument <Webpage>(pageId);
                return(document == null
                        ? string.Empty
                        : _formRenderer.RenderForm(document, status));
            });

            current = ThisPageFormMatch.Replace(current,
                                                match => _formRenderer.RenderForm(CurrentRequestData.CurrentPage, status));

            return(current);
        }
Ejemplo n.º 2
0
        public string Render(IHtmlHelper helper, Dictionary <string, string> attributes)
        {
            Webpage page;

            if (attributes.ContainsKey("id"))
            {
                int id;
                if (!int.TryParse(attributes["id"], out id))
                {
                    return(string.Empty);
                }
                page = _session.Get <Webpage>(id);
            }
            else
            {
                page = CurrentRequestData.CurrentPage;
            }

            var status = GetStatus(helper.ViewContext);

            return(_formRenderer.RenderForm(helper, page, status));
        }