/// <summary> /// Defines the shapes required for the editor view. /// </summary> /// <param name="part">The part.</param> /// <param name="shapeHelper">The shape helper.</param> protected override DriverResult Editor(ContactFormPart part, dynamic shapeHelper) { if (part == null) { part = new ContactFormPart(); } var editModel = new ContactFormEditModel { BasePath = _utilsServices.VirtualMediaPath, ContactForm = part }; return(ContentShape("Parts_ContactForm_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts/ContactForm", Model: editModel, Prefix: Prefix))); }
/// <summary> /// Runs upon the POST of the editor view. /// </summary> /// <param name="part">The part.</param> /// <param name="updater">The updater.</param> /// <param name="shapeHelper">The shape helper.</param> protected override DriverResult Editor(ContactFormPart part, IUpdateModel updater, dynamic shapeHelper) { if (part == null || updater == null) { return(Editor(null, shapeHelper)); } var editModel = new ContactFormEditModel { BasePath = _utilsServices.VirtualMediaPath, ContactForm = part }; if (updater.TryUpdateModel(editModel, Prefix, null, null)) { if (!editModel.ContactForm.DisplayNameField) { editModel.ContactForm.RequireNameField = false; } if (!string.IsNullOrWhiteSpace(editModel.ContactForm.PathUpload)) { if (!_storageProvider.FolderExists(editModel.ContactForm.PathUpload)) { if (_storageProvider.TryCreateFolder(editModel.ContactForm.PathUpload)) { _notifier.Information(T("The destination folder for the uploaded files has been succesfully created!")); } else { _notifier.Error(T("The destination folder for the uploaded files has not been created!")); } } } } return(Editor(editModel.ContactForm, shapeHelper)); }