public CategoryEditAdminViewModel(ProductCategory productCategory, UserProfile userProfile) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (productCategory == null) { throw new ArgumentNullException("productCategory", "Product Category cannot be null"); } LoadValues(userProfile, productCategory); }
public CategoryEditAdminViewModel(ProductCategory productCategory, UserProfile userProfile, string activeTab, bool isCreatePage = false, bool isSimpleCreatePage = false, bool isEditPage = false, bool isDetailsPage = false, bool isDeletePage = false) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (productCategory == null) { throw new ArgumentNullException("productCategory", "Product Category cannot be null"); } this.IsCreatePage = isCreatePage; this.IsSimpleCreatePage = isSimpleCreatePage; this.IsEditPage = isEditPage; this.IsDetailsPage = isDetailsPage; this.IsDeletePage = isDeletePage; this.ActiveTab = activeTab; LoadValues(userProfile, productCategory); }
protected ActionResult ViewCategory(ProductCategory category) { if (category == null) { throw new ApplicationException("Category is null, be sure category is set before calling ViewCategory"); } /// get current catalog item List<TreeNode<ProductCategory>> categoryTree = CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogByName(User.IsRegistered()); CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, categoryTree, CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, category, null, null, null); if (category.Theme != null) { ViewData.Theme(category.Theme); } return View("ViewCategory", this.LayoutNameForCatalog, model); }
protected void SetMetaTags(ProductCategory category) { StoreFrontConfiguration config = CurrentStoreFrontConfigOrThrow; _metaDescriptionOverride = category.MetaDescriptionOrSystemDefault(config); _metaKeywordsOverride = category.MetaKeywordsOrSystemDefault(config); }
/// <summary> /// Uses Category.UrlName to prevent dupes /// </summary> private static ProductCategory CreateSeedProductCategory(this IGstoreDb storeDb, string name, string urlName, int order, bool hideInMenuIfEmpty, ProductCategory parentProductCategory, StoreFront storeFront, bool linkRandomImage, bool returnCategoryIfExists) { if (storeFront.ProductCategories.Any(pc => pc.UrlName.ToLower() == urlName.ToLower())) { if (returnCategoryIfExists) { return storeFront.ProductCategories.Single(pc => pc.UrlName.ToLower() == urlName.ToLower()); } return null; } ProductCategory category = storeDb.ProductCategories.Create(); category.SetDefaultsForNew(storeFront); category.Name = name; category.UrlName = urlName.FixUrlName(); category.Order = order; category.HideInMenuIfEmpty = hideInMenuIfEmpty; if (parentProductCategory != null) { category.ParentCategory = parentProductCategory; } if (linkRandomImage) { category.ImageName = category.RandomImageName(); } storeDb.ProductCategories.Add(category); storeDb.SaveChangesEx(true, false, false, false); return category; }
/// <summary> /// Uses ProductBundle.UrlName to prevent dupes /// </summary> private static ProductBundle CreateSeedProductBundle(this IGstoreDb storeDb, string name, string urlName, int order, int maxQuantityPerOrder, bool linkRandomImage, ProductCategory category, StoreFront storeFront, bool availableForPurchase, bool returnProductBundleIfExists, bool updateCategoryCounts) { if (storeFront.ProductBundles.Any(b => b.UrlName.ToLower() == urlName.ToLower())) { if (returnProductBundleIfExists) { return storeFront.ProductBundles.Single(b => b.UrlName.ToLower() == urlName.ToLower()); } return null; } ProductBundle productBundle = storeDb.ProductBundles.Create(); productBundle.Client = storeFront.Client; productBundle.StoreFront = storeFront; productBundle.Name = name; if (!urlName.IsValidUrlName()) { urlName = urlName.FixUrlName(); } productBundle.UrlName = urlName; productBundle.Order = order; productBundle.MaxQuantityPerOrder = maxQuantityPerOrder; productBundle.IsPending = false; productBundle.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); productBundle.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); productBundle.Category = category; productBundle.SummaryCaption = "Summary for " + productBundle.Name; productBundle.SummaryHtml = "Summary has not been entered yet for " + productBundle.Name; productBundle.TopDescriptionCaption = "Description for " + productBundle.Name; productBundle.TopDescriptionHtml = "Description has not been entered yet for " + productBundle.Name; productBundle.TopLinkLabel = null; productBundle.TopLinkHref = null; productBundle.BottomDescriptionCaption = "Details for " + productBundle.Name; productBundle.BottomDescriptionHtml = "Details have not been entered yet for " + productBundle.Name; productBundle.ProductTypeSingle = null; productBundle.ProductTypePlural = null; productBundle.BottomLinkLabel = null; productBundle.BottomLinkHref = null; productBundle.ProductBundleDetailTemplate = ProductBundleDetailTemplateEnum.Default; productBundle.AvailableForPurchase = availableForPurchase; productBundle.ForAnonymousOnly = false; productBundle.ForRegisteredOnly = false; if (linkRandomImage) { productBundle.ImageName = productBundle.RandomImageName(); } storeDb.ProductBundles.Add(productBundle); storeDb.SaveChangesEx(true, false, false, updateCategoryCounts); return productBundle; }
/// <summary> /// Uses Product.UrlName to prevent dupes /// </summary> private static Product CreateSeedProduct(this IGstoreDb storeDb, string name, string urlName, int order, int maxQuantityPerOrder, ProductCategory category, StoreFront storeFront, bool availableForPurchase, bool linkRandomImage, decimal baseUnitPrice, decimal baseListPrice, bool updateCategoryCounts, bool returnProductIfExists) { if (storeFront.Products.Any(p => p.UrlName.ToLower() == urlName.ToLower())) { if (returnProductIfExists) { return storeFront.Products.Single(p => p.UrlName.ToLower() == urlName.ToLower()); } return null; } Product product = storeDb.Products.Create(); product.Client = storeFront.Client; product.StoreFront = storeFront; product.Name = name; if (!urlName.IsValidUrlName()) { urlName = urlName.FixUrlName(); } product.UrlName = urlName; product.Order = order; product.MaxQuantityPerOrder = maxQuantityPerOrder; product.IsPending = false; product.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); product.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); product.Category = category; product.BaseListPrice = baseListPrice; product.BaseUnitPrice = baseUnitPrice; product.SummaryCaption = null; product.SummaryHtml = product.Name + " is available for a limited time."; product.TopDescriptionCaption = null; product.TopDescriptionHtml = product.Name + " is a good fit for anyone interested in expanding their collection."; product.TopLinkLabel = null; product.TopLinkHref = null; product.BottomDescriptionCaption = null; product.BottomDescriptionHtml = "Note: This is a sample product."; product.BottomLinkLabel = null; product.BottomLinkHref = null; product.ProductDetailTemplate = ProductDetailTemplateEnum.Default; product.AvailableForPurchase = availableForPurchase; if (linkRandomImage) { product.ImageName = product.RandomImageName(); } storeDb.Products.Add(product); storeDb.SaveChangesEx(true, false, false, updateCategoryCounts); return product; }
protected void LoadValues(UserProfile userProfile, ProductCategory productCategory) { if (productCategory == null) { return; } this.IsActiveDirect = productCategory.IsActiveDirect(); this.IsActiveBubble = productCategory.IsActiveBubble(); this.ProductCategory = productCategory; this.Client = productCategory.Client; this.ClientId = (productCategory.Client == null ? 0 : productCategory.ClientId); this.CreateDateTimeUtc = productCategory.CreateDateTimeUtc; this.CreatedBy = productCategory.CreatedBy; this.CreatedBy_UserProfileId = productCategory.CreatedBy_UserProfileId; this.EndDateTimeUtc = productCategory.EndDateTimeUtc; this.ForRegisteredOnly = productCategory.ForRegisteredOnly; this.ForAnonymousOnly = productCategory.ForAnonymousOnly; this.IsPending = productCategory.IsPending; this.Name = productCategory.Name; this.UrlName = productCategory.UrlName; this.ProductCategoryId = productCategory.ProductCategoryId; this.Order = productCategory.Order; this.ParentCategory = productCategory.ParentCategory; this.ParentCategoryId = productCategory.ParentCategoryId; this.ProductTypeSingle = productCategory.ProductTypeSingle; this.ProductTypePlural = productCategory.ProductTypePlural; this.BundleTypeSingle = productCategory.BundleTypeSingle; this.BundleTypePlural = productCategory.BundleTypePlural; this.StartDateTimeUtc = productCategory.StartDateTimeUtc; this.StoreFront = productCategory.StoreFront; this.StoreFrontId = productCategory.StoreFrontId; this.UpdateDateTimeUtc = productCategory.UpdateDateTimeUtc; this.UpdatedBy = productCategory.UpdatedBy; this.UpdatedBy_UserProfileId = productCategory.UpdatedBy_UserProfileId; this.UseDividerAfterOnMenu = productCategory.UseDividerAfterOnMenu; this.UseDividerBeforeOnMenu = productCategory.UseDividerBeforeOnMenu; this.ShowInMenu = productCategory.ShowInMenu; this.HideInMenuIfEmpty = productCategory.HideInMenuIfEmpty; this.ShowInCatalogIfEmpty = productCategory.ShowInCatalogIfEmpty; this.DisplayForDirectLinks = productCategory.DisplayForDirectLinks; this.AllowChildCategoriesInMenu = productCategory.AllowChildCategoriesInMenu; this.ShowTop10ChildProductsInMenu = productCategory.ShowTop10ChildProductsInMenu; this.ImageName = productCategory.ImageName; this.ThemeId = productCategory.ThemeId; this.Theme = productCategory.Theme; this.CategoryDetailTemplate = productCategory.CategoryDetailTemplate; this.ProductListTemplate = productCategory.ProductListTemplate; this.BundleListTemplate = productCategory.BundleListTemplate; this.ProductDetailTemplate = productCategory.ProductDetailTemplate; this.ChildCategoryHeaderHtml = productCategory.ChildCategoryHeaderHtml; this.ChildCategoryFooterHtml = productCategory.ChildCategoryFooterHtml; this.ProductHeaderHtml = productCategory.ProductHeaderHtml; this.ProductFooterHtml = productCategory.ProductFooterHtml; this.NoProductsMessageHtml = productCategory.NoProductsMessageHtml; this.DefaultSummaryCaption = productCategory.DefaultSummaryCaption; this.DefaultTopDescriptionCaption = productCategory.DefaultTopDescriptionCaption; this.DefaultBottomDescriptionCaption = productCategory.DefaultBottomDescriptionCaption; this.DefaultSampleImageCaption = productCategory.DefaultSampleImageCaption; this.DefaultSampleAudioCaption = productCategory.DefaultSampleAudioCaption; this.DefaultSampleDownloadCaption = productCategory.DefaultSampleDownloadCaption; this.MetaDescription = productCategory.MetaDescription; this.MetaKeywords = productCategory.MetaKeywords; }
public void UpdateProductCategoryAndParent(ProductCategory productCategory) { this.ProductCategory = productCategory; this.ParentCategory = productCategory.ParentCategory; }