public WebFormFieldEditAdminViewModel(WebFormEditAdminViewModel WebFormEditAdminViewModel, WebFormField webFormField, int index) { if (WebFormEditAdminViewModel == null) { throw new ArgumentNullException("WebFormEditAdminViewModel"); } if (WebFormEditAdminViewModel.WebForm == null) { throw new ArgumentNullException("WebFormEditAdminViewModel.WebForm", "WebFormEditAdminViewModel.WebForm cannot be null. make sure page edit sets this after post"); } this.Index = index; this.WebFormEditAdminViewModel = WebFormEditAdminViewModel; this.WebForm = WebFormEditAdminViewModel.WebForm; this.WebFormId = WebFormEditAdminViewModel.WebForm.WebFormId; this.IsStoreAdminEdit = WebFormEditAdminViewModel.IsStoreAdminEdit; this.IsReadOnly = WebFormEditAdminViewModel.IsReadOnly; this.IsDeletePage = WebFormEditAdminViewModel.IsDeletePage; this.IsCreatePage = WebFormEditAdminViewModel.IsCreatePage; this.ActiveTab = WebFormEditAdminViewModel.ActiveTab; SetDefaults(WebFormEditAdminViewModel); if (webFormField != null) { this.Name = webFormField.Name; this.DataType = webFormField.DataType; this.DataTypeString = webFormField.DataTypeString; this.Description = webFormField.Description; this.EndDateTimeUtc = webFormField.EndDateTimeUtc; this.HelpLabelBottomText = webFormField.HelpLabelBottomText; this.HelpLabelTopText = webFormField.HelpLabelTopText; this.IsPending = webFormField.IsPending; this.IsRequired = webFormField.IsRequired; this.LabelText = webFormField.LabelText; this.Watermark = webFormField.Watermark; this.Order = webFormField.Order; this.StartDateTimeUtc = webFormField.StartDateTimeUtc; this.TextAreaColumns = webFormField.TextAreaColumns; this.TextAreaRows = webFormField.TextAreaRows; this.ValueList = webFormField.ValueList; this.ValueListId = webFormField.ValueListId; this.WebFormFieldId = webFormField.WebFormFieldId; this.WebFormFieldResponses = webFormField.WebFormFieldResponses; this.IsActiveDirect = webFormField.IsActiveDirect(); this.IsActiveBubble = webFormField.IsActiveBubble(); FillListsIfEmpty(webFormField.Client); } }
public WebFormFieldEditAdminViewModel(WebFormEditAdminViewModel WebFormEditAdminViewModel, WebFormField webFormField, int index) { if (WebFormEditAdminViewModel == null) { throw new ArgumentNullException("WebFormEditAdminViewModel"); } if (WebFormEditAdminViewModel.WebForm == null) { throw new ArgumentNullException("WebFormEditAdminViewModel.WebForm", "WebFormEditAdminViewModel.WebForm cannot be null. make sure page edit sets this after post"); } this.Index = index; this.WebFormEditAdminViewModel = WebFormEditAdminViewModel; this.WebForm = WebFormEditAdminViewModel.WebForm; this.WebFormId = WebFormEditAdminViewModel.WebForm.WebFormId; this.IsStoreAdminEdit = WebFormEditAdminViewModel.IsStoreAdminEdit; this.IsReadOnly = WebFormEditAdminViewModel.IsReadOnly; this.IsDeletePage = WebFormEditAdminViewModel.IsDeletePage; this.IsCreatePage = WebFormEditAdminViewModel.IsCreatePage; this.ActiveTab = WebFormEditAdminViewModel.ActiveTab; SetDefaults(WebFormEditAdminViewModel); if (webFormField != null) { this.Name = webFormField.Name; this.DataType = webFormField.DataType; this.DataTypeString = webFormField.DataTypeString; this.Description = webFormField.Description; this.EndDateTimeUtc = webFormField.EndDateTimeUtc; this.HelpLabelBottomText = webFormField.HelpLabelBottomText; this.HelpLabelTopText = webFormField.HelpLabelTopText; this.IsPending = webFormField.IsPending; this.IsRequired = webFormField.IsRequired; this.LabelText = webFormField.LabelText; this.Watermark = webFormField.Watermark; this.Order = webFormField.Order; this.StartDateTimeUtc = webFormField.StartDateTimeUtc; this.TextAreaColumns = webFormField.TextAreaColumns; this.TextAreaRows = webFormField.TextAreaRows; this.ValueList = webFormField.ValueList; this.ValueListId = webFormField.ValueListId; this.WebFormFieldId = webFormField.WebFormFieldId; this.WebFormFieldResponses = webFormField.WebFormFieldResponses; this.IsActiveDirect = webFormField.IsActiveDirect(); this.IsActiveBubble = webFormField.IsActiveBubble(); FillListsIfEmpty(webFormField.Client); } }
protected void SetDefaults(WebFormEditAdminViewModel WebFormEditAdminViewModel) { if (WebFormEditAdminViewModel == null) { return; } this.Name = "New Field"; this.Order = 100; if (WebFormEditAdminViewModel.WebForm != null && WebFormEditAdminViewModel.WebForm.WebFormFields.Count > 0) { this.Order = WebFormEditAdminViewModel.WebFormFields.Max(wff => wff.Order) + 10; bool nameIsDirty = WebFormEditAdminViewModel.WebForm.WebFormFields.Any(wff => wff.Name.ToLower() == this.Name.ToLower()); if (nameIsDirty) { int counter = 1; do { counter++; this.Name = "New Field " + counter; nameIsDirty = WebFormEditAdminViewModel.WebForm.WebFormFields.Any(wff => wff.Name.ToLower() == this.Name.ToLower()); } while (nameIsDirty); } } this.WebForm = WebFormEditAdminViewModel.WebForm; this.WebFormId = WebFormEditAdminViewModel.WebForm.WebFormId; this.IsPending = false; this.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); this.StartDateTimeUtc = DateTime.UtcNow.AddYears(100); this.DataType = GStoreValueDataType.SingleLineText; this.DataTypeString = this.DataType.ToDisplayName(); this.Description = this.Name; this.IsRequired = false; this.LabelText = "Text"; this.Watermark = this.Name; this.HelpLabelBottomText = "Enter text here"; this.TextAreaColumns = null; this.TextAreaRows = null; }
protected void SetDefaults(WebFormEditAdminViewModel WebFormEditAdminViewModel) { if (WebFormEditAdminViewModel == null) { return; } this.Name = "New Field"; this.Order = 100; if (WebFormEditAdminViewModel.WebForm != null && WebFormEditAdminViewModel.WebForm.WebFormFields.Count > 0) { this.Order = WebFormEditAdminViewModel.WebFormFields.Max(wff => wff.Order) + 10; bool nameIsDirty = WebFormEditAdminViewModel.WebForm.WebFormFields.Any(wff => wff.Name.ToLower() == this.Name.ToLower()); if (nameIsDirty) { int counter = 1; do { counter++; this.Name = "New Field " + counter; nameIsDirty = WebFormEditAdminViewModel.WebForm.WebFormFields.Any(wff => wff.Name.ToLower() == this.Name.ToLower()); } while (nameIsDirty); } } this.WebForm = WebFormEditAdminViewModel.WebForm; this.WebFormId = WebFormEditAdminViewModel.WebForm.WebFormId; this.IsPending = false; this.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); this.StartDateTimeUtc = DateTime.UtcNow.AddYears(100); this.DataType = GStoreValueDataType.SingleLineText; this.DataTypeString = this.DataType.ToDisplayName(); this.Description = this.Name; this.IsRequired = false; this.LabelText = "Text"; this.Watermark = this.Name; this.HelpLabelBottomText = "Enter text here"; this.TextAreaColumns = null; this.TextAreaRows = null; }
public static WebFormField CreateWebFormFieldFastAdd(this IGstoreDb db, WebFormEditAdminViewModel viewModel, string FastAddField, StoreFront storeFront, UserProfile userProfile) { if (string.IsNullOrWhiteSpace(FastAddField)) { throw new ArgumentNullException("FastAddField"); } if (viewModel == null) { throw new ArgumentNullException("viewModel"); } if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (viewModel.WebForm != null) { } WebFormField webFormField = db.WebFormFields.Create(); webFormField.SetDefaultsForNew(viewModel.WebForm); webFormField.Client = storeFront.Client; webFormField.ClientId = storeFront.ClientId; webFormField.CreateDateTimeUtc = DateTime.UtcNow; webFormField.CreatedBy = userProfile; webFormField.CreatedBy_UserProfileId = userProfile.UserProfileId; webFormField.Description = FastAddField; webFormField.HelpLabelBottomText = null; webFormField.HelpLabelTopText = null; webFormField.IsRequired = false; webFormField.LabelText = FastAddField; webFormField.Watermark = FastAddField; webFormField.Name = FastAddField; webFormField.TextAreaColumns = null; webFormField.TextAreaRows = null; webFormField.WebForm = viewModel.WebForm; webFormField.WebFormId = viewModel.WebFormId; webFormField.UpdateAuditFields(userProfile); webFormField = db.WebFormFields.Add(webFormField); db.SaveChanges(); return webFormField; }
public static WebForm CreateWebForm(this IGstoreDb db, WebFormEditAdminViewModel viewModel, StoreFront storeFront, UserProfile userProfile) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } WebForm webForm = db.WebForms.Create(); webForm.Client = storeFront.Client; webForm.ClientId = storeFront.ClientId; webForm.CreateDateTimeUtc = DateTime.UtcNow; webForm.CreatedBy = userProfile; webForm.CreatedBy_UserProfileId = userProfile.UserProfileId; webForm.Description = viewModel.Description; webForm.DisplayTemplateName = viewModel.DisplayTemplateName; webForm.EndDateTimeUtc = viewModel.EndDateTimeUtc; webForm.FieldMdColSpan = viewModel.FieldMdColSpan; webForm.FormFooterAfterSubmitHtml = viewModel.FormFooterAfterSubmitHtml; webForm.FormFooterBeforeSubmitHtml = viewModel.FormFooterBeforeSubmitHtml; webForm.FormHeaderHtml = viewModel.FormHeaderHtml; webForm.IsPending = viewModel.IsPending; webForm.LabelMdColSpan = viewModel.LabelMdColSpan; webForm.Name = viewModel.Name; webForm.Order = viewModel.Order; webForm.StartDateTimeUtc = viewModel.StartDateTimeUtc; webForm.SubmitButtonClass = viewModel.SubmitButtonClass; webForm.SubmitButtonText = viewModel.SubmitButtonText; webForm.Title = viewModel.Title; webForm.UpdateDateTimeUtc = DateTime.UtcNow; webForm.UpdatedBy = userProfile; webForm.UpdatedBy_UserProfileId = userProfile.UserProfileId; webForm.UpdateAuditFields(userProfile); webForm = db.WebForms.Add(webForm); db.SaveChanges(); return webForm; }
public static WebForm UpdateWebForm(this IGstoreDb db, WebFormEditAdminViewModel viewModel, StoreFront storeFront, UserProfile userProfile) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } if (storeFront == null) { throw new ArgumentNullException("storeFront"); } if (userProfile == null) { throw new ArgumentNullException("userProfile"); } //find existing record, update it WebForm webForm = storeFront.Client.WebForms.SingleOrDefault(p => p.WebFormId == viewModel.WebFormId); if (webForm == null) { throw new ApplicationException("Web Form not found in client web forms. Web Form Id: " + viewModel.WebFormId + " Client '" + storeFront.Client.Name + " [" + storeFront.ClientId + "]"); } webForm.Description = viewModel.Description; webForm.DisplayTemplateName = viewModel.DisplayTemplateName; webForm.EndDateTimeUtc = viewModel.EndDateTimeUtc; webForm.FieldMdColSpan = viewModel.FieldMdColSpan; webForm.FormFooterAfterSubmitHtml = viewModel.FormFooterAfterSubmitHtml; webForm.FormFooterBeforeSubmitHtml = viewModel.FormFooterBeforeSubmitHtml; webForm.FormHeaderHtml = viewModel.FormHeaderHtml; webForm.IsPending = viewModel.IsPending; webForm.LabelMdColSpan = viewModel.LabelMdColSpan; webForm.Name = viewModel.Name; webForm.Order = viewModel.Order; webForm.StartDateTimeUtc = viewModel.StartDateTimeUtc; webForm.SubmitButtonClass = viewModel.SubmitButtonClass; webForm.SubmitButtonText = viewModel.SubmitButtonText; webForm.Title = viewModel.Title; webForm.UpdateDateTimeUtc = DateTime.UtcNow; webForm.UpdatedBy = userProfile; webForm.UpdatedBy_UserProfileId = userProfile.UserProfileId; webForm.UpdateAuditFields(userProfile); webForm = db.WebForms.Update(webForm); db.SaveChanges(); return webForm; }