public WebFormEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, WebForm webForm, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool? sortAscending = true) { if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (webForm == null) { throw new ArgumentNullException("webForm", "Web form cannot be null"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsActiveDirect = webForm.IsActiveDirect(); this.IsActiveBubble = webForm.IsActiveBubble(); this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.SortBy = sortBy; this.SortAscending = sortAscending; LoadValues(storeFront, userProfile, webForm); }
public ActionResult Create(WebForm webForm) { Client client = GStoreDb.Clients.FindById(webForm.ClientId); if (client.WebForms.Any(wf => wf.Name.ToLower() == webForm.Name.ToLower())) { ModelState.AddModelError("Name", "A Web Form with the name '" + webForm.Name + "' already exists. Change the name here or edit the conflicting web form."); } if (ModelState.IsValid) { webForm = GStoreDb.WebForms.Create(webForm); webForm.UpdateAuditFields(CurrentUserProfileOrThrow); webForm = GStoreDb.WebForms.Add(webForm); GStoreDb.SaveChanges(); AddUserMessage("Web Form Created", "Web Form '" + webForm.Name.ToHtml() + "' [" + webForm.WebFormId + "] Created Successfully", UserMessageType.Success); return RedirectToAction("Index"); } int? clientId = null; if (webForm.ClientId != default(int)) { clientId = webForm.ClientId; } this.BreadCrumbsFunc = htmlHelper => this.WebFormBreadcrumb(htmlHelper, webForm.ClientId, webForm); return View(webForm); }
protected void LoadValues(StoreFront storeFront, UserProfile userProfile, WebForm webForm) { if (webForm == null) { return; } this.WebForm = webForm; this.Client = webForm.Client; this.ClientId = (webForm.Client == null ? 0 : webForm.ClientId); this.CreateDateTimeUtc = webForm.CreateDateTimeUtc; this.CreatedBy = webForm.CreatedBy; this.CreatedBy_UserProfileId = webForm.CreatedBy_UserProfileId; this.Description = webForm.Description; this.DisplayTemplateName = webForm.DisplayTemplateName; this.EndDateTimeUtc = webForm.EndDateTimeUtc; this.FieldMdColSpan = webForm.FieldMdColSpan; this.FormFooterAfterSubmitHtml = webForm.FormFooterAfterSubmitHtml; this.FormFooterBeforeSubmitHtml = webForm.FormFooterBeforeSubmitHtml; this.FormHeaderHtml = webForm.FormHeaderHtml; this.IsPending = webForm.IsPending; this.LabelMdColSpan = webForm.LabelMdColSpan; this.Name = webForm.Name; this.Order = webForm.Order; this.Pages = webForm.Pages; this.StartDateTimeUtc = webForm.StartDateTimeUtc; this.SubmitButtonClass = webForm.SubmitButtonClass; this.SubmitButtonText = webForm.SubmitButtonText; this.Title = webForm.Title; this.UpdateDateTimeUtc = webForm.UpdateDateTimeUtc; this.UpdatedBy = webForm.UpdatedBy; this.UpdatedBy_UserProfileId = webForm.UpdatedBy_UserProfileId; this.WebFormFields = webForm.WebFormFields; this.WebFormId = webForm.WebFormId; this.WebFormResponses = webForm.WebFormResponses; this._webFormFieldViewModels = null; }
public void UpdateWebForm(WebForm webForm) { this.WebForm = webForm; }
public void FillFieldsFromViewModel(WebForm webFormToUpdate, WebFormFieldEditAdminViewModel[] webFormFields) { this.WebForm = webFormToUpdate; this.WebFormFields = webFormToUpdate.WebFormFields; this.webFormFieldPostData = webFormFields; this._webFormFieldViewModels = null; }
public static void SetDefaultsForNew(this WebFormField webFormField, WebForm webForm) { if (webForm != null) { webFormField.WebForm = webForm; webFormField.WebFormId = webForm.WebFormId; webFormField.ClientId = webForm.ClientId; webFormField.Order = webForm.WebFormFields.Count == 0 ? 100 : webForm.WebFormFields.Max(wf => wf.Order) + 10; webFormField.Name = "New Field"; bool nameIsDirty = webForm.WebFormFields.Any(wf => wf.Name.ToLower() == webFormField.Name.ToLower()); int counter = 1; do { counter++; webFormField.Name = "New Field " + counter; nameIsDirty = webForm.WebFormFields.Any(wf => wf.Name.ToLower() == webFormField.Name.ToLower()); } while (nameIsDirty); webFormField.LabelText = webFormField.Name; webFormField.Description = webFormField.Name; } webFormField.Watermark = webFormField.Name; webFormField.Description = webFormField.Name; webFormField.DataType = GStoreValueDataType.SingleLineText; webFormField.DataTypeString = webFormField.DataType.ToDisplayName(); webFormField.IsPending = false; webFormField.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); webFormField.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); }
public ActionResult Edit(WebForm webForm) { if (ModelState.IsValid) { webForm.UpdateAuditFields(CurrentUserProfileOrThrow); webForm = GStoreDb.WebForms.Update(webForm); GStoreDb.SaveChanges(); AddUserMessage("Web Form Updated", "Changes saved successfully to Web Form '" + webForm.Name.ToHtml() + "' [" + webForm.WebFormId + "]", UserMessageType.Success); return RedirectToAction("Index"); } this.BreadCrumbsFunc = htmlHelper => this.WebFormBreadcrumb(htmlHelper, webForm.ClientId, webForm); var errors = this.ModelState.Where(v => v.Value.Errors.Any()); return View(webForm); }
/// <summary> /// Not Dupe-safe /// </summary> private static WebFormField CreateSeedWebFormField(this IGstoreDb storeDb, WebForm webForm, string name, int order = 1000, string description = null, bool isRequired = false, string helpLabelBottomText = "", string helpLabelTopText = "", GStoreValueDataType? dataType = null) { if (webForm == null) { throw new ArgumentNullException("webForm"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } WebFormField webFormField = storeDb.WebFormFields.Create(); webFormField.SetDefaultsForNew(webForm); webFormField.Client = webForm.Client; webFormField.Name = name; webFormField.Description = description ?? name; webFormField.IsRequired = isRequired; webFormField.LabelText = name; webFormField.Order = order; webFormField.Watermark = webFormField.LabelText + (webFormField.IsRequired ? " (Required)" : ""); webFormField.HelpLabelBottomText = helpLabelBottomText; webFormField.HelpLabelTopText = helpLabelTopText; if (dataType.HasValue) { webFormField.DataType = dataType.Value; webFormField.DataTypeString = dataType.ToDisplayName(); } storeDb.WebFormFields.Add(webFormField); storeDb.SaveChangesEx(true, false, false, false); return webFormField; }
public CheckoutWebFormInfo(CheckoutViewModelBase checkoutViewModel, WebForm webForm, WebFormResponse webFormResponse) { this.CheckoutViewModel = checkoutViewModel; this.WebForm = webForm; this.WebFormResponse = webFormResponse; }
protected MvcHtmlString WebFormFieldsBreadcrumb(HtmlHelper htmlHelper, WebForm webForm, bool ShowAsLink = false) { return new MvcHtmlString( WebFormBreadcrumb(htmlHelper, webForm.ClientId, webForm, true).ToHtmlString() + " -> " + (ShowAsLink ? htmlHelper.ActionLink("Fields", "FieldIndex", "WebFormSysAdmin", new { id = webForm.WebFormId }, null).ToHtmlString() : "Fields") ); }
protected MvcHtmlString WebFormBreadcrumb(HtmlHelper htmlHelper, int? clientId, WebForm webForm, bool ShowAsLink = false) { RouteValueDictionary routeData = null; string name = "(unknown)"; bool showLink = false; if (webForm != null) { if (webForm.WebFormId == 0) { name = "New"; } else { showLink = ShowAsLink; routeData = new RouteValueDictionary(new { id = webForm.WebFormId }); name = "'" + webForm.Name + "' [" + webForm.WebFormId + "]"; } } return new MvcHtmlString( WebFormsBreadcrumb(htmlHelper, clientId, true).ToHtmlString() + " -> " + (showLink ? htmlHelper.ActionLink(name, "Details", "WebFormSysAdmin", routeData, null).ToHtmlString() : name) ); }