public PageEditViewModel(Page page, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string activeTab = "") { if (page == null) { throw new ArgumentNullException("page"); } this.IsStoreAdminEdit = isStoreAdminEdit; this.IsReadOnly = isReadOnly; this.IsDeletePage = isDeletePage; this.IsCreatePage = isCreatePage; this.ActiveTab = activeTab; this.CreateMenuItemWithPage = isCreatePage; LoadValues(page); }
public PageViewModel(Page page, bool showEditPageLink, bool viewMode, bool editMode, bool autoPost, bool forTemplateSyncOnly, int? pageTemplateIdForSync, bool syncExistingDefaults, string activeTab) { if (page == null && !forTemplateSyncOnly) { throw new ArgumentNullException("page", "page must be specified for page view model or forTemplateSyncOnly must be true"); } if (forTemplateSyncOnly && !pageTemplateIdForSync.HasValue) { throw new ArgumentNullException("pageTemplateIdForSync", "PageTemplateIdForSync must be specified when forTemplateSyncOnly is true"); } this.Page = page; this.ViewMode = viewMode; this.EditMode = editMode; this.AutoPost = autoPost; this.ShowEditPageLink = showEditPageLink; this.ForTemplateSyncOnly = forTemplateSyncOnly; this.PageTemplateIdForSync = pageTemplateIdForSync; this.ActiveTab = activeTab; }
public PageSectionEditViewModel(PageTemplateSection pageTemplateSection, Page page, PageSection pageSection, int index, bool autoSubmit) { if (pageTemplateSection == null) { throw new ArgumentNullException("pageTemplateSection"); } if (page == null) { throw new ArgumentNullException("page", "page must be specified and exist before editing page sections"); } if (index < 1) { throw new ArgumentOutOfRangeException("index", "Index cannot be 0, it starts from 1 and up"); } SetDefaults(pageTemplateSection); this.PageTemplateSectionId = pageTemplateSection.PageTemplateSectionId; this.SectionName = pageTemplateSection.Name; this.DefaultRawHtmlValue = pageTemplateSection.DefaultRawHtmlValue; this.PageId = page.PageId; this.Index = index; this.AutoSubmit = autoSubmit; if (pageSection != null) { this.PageSectionId = pageSection.PageSectionId; this.UseDefaultFromTemplate = pageSection.UseDefaultFromTemplate; this.HasNothing = pageSection.HasNothing; this.HasPlainText = pageSection.HasPlainText; this.HasRawHtml = pageSection.HasRawHtml; this.Order = pageSection.Order; this.PageId = pageSection.PageId; this.PlainText = pageSection.PlainText; this.RawHtml = pageSection.RawHtml; this.StartDateTimeUtc = pageSection.StartDateTimeUtc; this.EndDateTimeUtc = pageSection.EndDateTimeUtc; this.IsPending = pageSection.IsPending; this.UpdateDateTimeUtc = pageSection.UpdateDateTimeUtc; this.UpdatedBy = pageSection.UpdatedBy; } }
protected void SetMetaTags(Page page) { if (page == null) { return; } if (!string.IsNullOrEmpty(page.MetaApplicationName)) { _metaApplicationNameOverride = page.MetaApplicationName; } if (!string.IsNullOrEmpty(page.MetaApplicationTileColor)) { _metaApplicationTileColorOverride = page.MetaApplicationTileColor; } if (!string.IsNullOrEmpty(page.MetaDescription)) { _metaDescriptionOverride = page.MetaDescription; } if (!string.IsNullOrEmpty(page.MetaKeywords)) { _metaKeywordsOverride = page.MetaKeywords; } if (!string.IsNullOrEmpty(page.BodyTopScriptTag)) { _bodyTopScriptTagOverride = page.BodyTopScriptTag; } if (!string.IsNullOrEmpty(page.BodyBottomScriptTag)) { _bodyBottomScriptTagOverride = page.BodyBottomScriptTag; } }
protected void LoadValues(Page page) { if (page == null) { this.IsPending = false; this.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); this.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); return; } this.BodyBottomScriptTag = page.BodyBottomScriptTag; this.BodyTopScriptTag = page.BodyTopScriptTag; this.MetaDescription = page.MetaDescription; this.MetaKeywords = page.MetaKeywords; this.MetaApplicationName = page.MetaApplicationName; this.MetaApplicationTileColor = page.MetaApplicationTileColor; this.Name = page.Name; this.OriginalPageUrl = page.Url; this.OriginalPageTemplate = page.PageTemplate; this.OriginalTheme = page.Theme; this.OriginalWebForm = page.WebForm; this.Order = page.Order; this.PageId = page.PageId; this.PageTemplateId = page.PageTemplateId; this.PageTemplateName = (page.PageTemplate == null ? null : page.PageTemplate.Name); this.PageTitle = page.PageTitle; this.ForAnonymousOnly = page.ForAnonymousOnly; this.ForRegisteredOnly = page.ForRegisteredOnly; this.ThemeId = page.ThemeId; this.Url = page.Url; this.CreatedBy = page.CreatedBy; this.CreateDateTimeUtc = page.CreateDateTimeUtc; this.UpdatedBy = page.UpdatedBy; this.UpdateDateTimeUtc = page.UpdateDateTimeUtc; this.IsPending = page.IsPending; this.StartDateTimeUtc = page.StartDateTimeUtc; this.EndDateTimeUtc = page.EndDateTimeUtc; this.StoreFront = page.StoreFront; this.StoreFrontId = page.StoreFrontId; this.WebFormId = page.WebFormId; this.WebFormEmailToAddress = page.WebFormEmailToAddress; this.WebFormEmailToName = page.WebFormEmailToName; this.WebFormSuccessPageId = page.WebFormSuccessPageId; this.WebFormThankYouTitle = page.WebFormThankYouTitle; this.WebFormThankYouMessage = page.WebFormThankYouMessage; this.WebFormSaveToDatabase = page.WebFormSaveToDatabase; this.WebFormSaveToFile = page.WebFormSaveToFile; this.WebFormSendToEmail = page.WebFormSendToEmail; this.WebFormSaveToDatabase = page.WebFormSaveToDatabase; this.PageTemplateSelectList = page.Client.PageTemplates.AsQueryable().ToSelectList(page.PageTemplateId).ToList(); this.ThemeSelectList = page.Client.Themes.AsQueryable().ToSelectList(page.ThemeId).ToList(); this.WebFormSelectList = page.Client.WebForms.AsQueryable().ToSelectListWithNull(page.WebFormId).ToList(); this.WebFormSuccessPageSelectList = page.StoreFront.Pages.AsQueryable().ToSelectListWithNull(page.WebFormSuccessPageId).ToList(); if (page.PageTemplate != null) { List<PageTemplateSection> variableTemplateSections = page.PageTemplate.Sections.Where(pts => pts.IsVariable).AsQueryable().ApplyDefaultSort().ToList(); this.Variables = variableTemplateSections.Select(pts => new PageVariableEditViewModel(page.PageId, pts, pts.PageSections.AsQueryable().WhereIsActive().FirstOrDefault(ps => ps.PageId == page.PageId))).ToList(); } this.IsActiveBubble = page.IsActiveBubble(); this.IsActiveDirect = page.IsActiveDirect(); }
public static NavBarItem CreateNavBarItemForPage(this IGstoreDb db, Page page, StoreFront storeFront, UserProfile userProfile) { NavBarItem record = db.NavBarItems.Create(); string navBarItemName = page.Name; bool nameIsValid = db.ValidateNavBarItemName(null, navBarItemName, storeFront.StoreFrontId, storeFront.ClientId, null); if (!nameIsValid) { int index = 1; do { navBarItemName = page.Name + "_" + index; nameIsValid = db.ValidateNavBarItemName(null, navBarItemName, storeFront.StoreFrontId, storeFront.ClientId, null); } while (!nameIsValid); } record.Name = navBarItemName; record.Order = (storeFront.Pages == null ? 100 : storeFront.Pages.Max(pg => pg.Order) + 10); record.ForAnonymousOnly = page.ForAnonymousOnly; record.ForRegisteredOnly = page.ForRegisteredOnly; record.IsPage = true; record.PageId = page.PageId; record.StoreFrontId = storeFront.StoreFrontId; record.ClientId = storeFront.ClientId; record.IsPending = false; record.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); record.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); record.UpdateAuditFields(userProfile); db.NavBarItems.Add(record); db.SaveChanges(); return record; }