/// <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 } }; }
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); } } } } }
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; }
internal static NameValueCollection FetchPostedValues(this Controller controller, Form form) { return (NameValueCollection)controller.TempData[String.Format("Form_Values_{0}", form.Name)] ?? new NameValueCollection(); }
internal static ModelStateDictionary FetchModelState(this Controller controller, Form form) { return (ModelStateDictionary)controller.TempData[String.Format("Form_ModelState_{0}", form.Name)]; }