コード例 #1
0
 /// <summary>
 /// Generates a permission dynamically for a content type
 /// </summary>
 public static Permission CreateSubmitPermission(Form form) {
     return new Permission {
         Name = String.Format(SubmitForm.Name, form.Name),
         Description = String.Format(SubmitForm.Description, form.Name),
         Category = "Dynamic Forms",
         ImpliedBy = new [] { SubmitForm }
     };
 }
コード例 #2
0
        internal static void ApplyAnyModelErrors(this Controller controller, Form form, ModelStateDictionary modelState) {
            var hasErrors = modelState != null && !modelState.IsValid;

            if (hasErrors) {
                foreach (var state in modelState) {
                    if (state.Value.Errors.Any()) {
                        foreach (var error in state.Value.Errors) {
                            controller.ModelState.AddModelError(state.Key, error.ErrorMessage);
                        }
                    }
                }
            }
        }
コード例 #3
0
 internal static void TransferFormSubmission(this Controller controller, Form form, NameValueCollection values) {
     controller.TempData[String.Format("Form_ModelState_{0}", form.Name)] = controller.ModelState;
     controller.TempData[String.Format("Form_Values_{0}", form.Name)] = values;
 }
コード例 #4
0
 internal static NameValueCollection FetchPostedValues(this Controller controller, Form form) {
     return (NameValueCollection)controller.TempData[String.Format("Form_Values_{0}", form.Name)] ?? new NameValueCollection();
 }
コード例 #5
0
 internal static ModelStateDictionary FetchModelState(this Controller controller, Form form) {
     return (ModelStateDictionary)controller.TempData[String.Format("Form_ModelState_{0}", form.Name)];
 }