コード例 #1
0
        /// <summary>
        /// Creates a view model for the specified form, layout, and template.
        /// </summary>
        /// <param name="formId">
        /// The form ID.
        /// </param>
        /// <param name="layoutId">
        /// The layout ID.
        /// </param>
        /// <param name="templateId">
        /// The template ID.
        /// </param>
        /// <returns>
        /// The view model.
        /// </returns>
        /// <remarks>
        /// This model is used to render a form.
        /// </remarks>
        public static FormViewModel GetFormViewModel(Guid?formId, Guid?layoutId, Guid?templateId)
        {
            var model = new FormViewModel();

            model.FormDefinition   = DefinitionHelper.GetFormDefinition(formId);
            model.LayoutDefinition = DefinitionHelper.GetLayoutDefinition(layoutId);
            model.TemplatePath     = DefinitionHelper.GetTemplatePath(templateId);
            return(model);
        }
コード例 #2
0
        /// <summary>
        /// Creates a view model for the specified form, layout, and template.
        /// </summary>
        /// <param name="formId">
        /// The form ID.
        /// </param>
        /// <param name="layoutId">
        /// The layout ID.
        /// </param>
        /// <param name="templateId">
        /// The template ID.
        /// </param>
        /// <param name="page">
        /// The current Umbraco page.
        /// </param>
        /// <returns>
        /// The view model.
        /// </returns>
        /// <remarks>
        /// This model is used to render a form.
        /// </remarks>
        public static FormViewModel GetFormViewModel(Guid?formId, Guid?layoutId,
                                                     Guid?templateId, IPublishedContent page)
        {
            var model = new FormViewModel()
            {
                FormDefinition   = DefinitionHelper.GetFormDefinition(formId),
                LayoutDefinition = DefinitionHelper.GetLayoutDefinition(layoutId),
                TemplatePath     = DefinitionHelper.GetTemplatePath(templateId),
                PageId           = page.Id
            };

            return(model);
        }