public ProductBundleEditAdminViewModel(ProductBundle productBundle, UserProfile userProfile) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (productBundle == null) { throw new ArgumentNullException("productBundle", "Product Bundle cannot be null"); } LoadValues(userProfile, productBundle); }
public ProductBundleEditAdminViewModel(ProductBundle productBundle, UserProfile userProfile, string activeTab, bool isCreatePage = false, bool isEditPage = false, bool isDetailsPage = false, bool isDeletePage = false) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (productBundle == null) { throw new ArgumentNullException("productBundle", "Product Bundle cannot be null"); } this.IsCreatePage = isCreatePage; this.IsEditPage = isEditPage; this.IsDetailsPage = isDetailsPage; this.IsDeletePage = isDeletePage; this.ActiveTab = activeTab; LoadValues(userProfile, productBundle); }
protected void LoadValues(UserProfile userProfile, ProductBundle productBundle) { if (productBundle == null) { return; } this.IsActiveDirect = productBundle.IsActiveDirect(); this.IsActiveBubble = productBundle.IsActiveBubble(); this.ProductBundle = productBundle; this.Client = productBundle.Client; this.ClientId = (productBundle.Client == null ? 0 : productBundle.ClientId); this.CreateDateTimeUtc = productBundle.CreateDateTimeUtc; this.CreatedBy = productBundle.CreatedBy; this.CreatedBy_UserProfileId = productBundle.CreatedBy_UserProfileId; this.EndDateTimeUtc = productBundle.EndDateTimeUtc; this.ForRegisteredOnly = productBundle.ForRegisteredOnly; this.ForAnonymousOnly = productBundle.ForAnonymousOnly; this.IsPending = productBundle.IsPending; this.Name = productBundle.Name; this.UrlName = productBundle.UrlName; this.ImageName = productBundle.ImageName; this.ProductBundleId = productBundle.ProductBundleId; this.Order = productBundle.Order; this.Category = productBundle.Category; this.ProductCategoryId = productBundle.ProductCategoryId; this.StartDateTimeUtc = productBundle.StartDateTimeUtc; this.StoreFront = productBundle.StoreFront; this.StoreFrontId = productBundle.StoreFrontId; this.UpdateDateTimeUtc = productBundle.UpdateDateTimeUtc; this.UpdatedBy = productBundle.UpdatedBy; this.UpdatedBy_UserProfileId = productBundle.UpdatedBy_UserProfileId; this.MaxQuantityPerOrder = productBundle.MaxQuantityPerOrder; this.MetaDescription = productBundle.MetaDescription; this.MetaKeywords = productBundle.MetaKeywords; this.AvailableForPurchase = productBundle.AvailableForPurchase; this.RequestAQuote_Show = productBundle.RequestAQuote_Show; this.RequestAQuote_Label = productBundle.RequestAQuote_Label; this.RequestAQuote_PageId = productBundle.RequestAQuote_PageId; this.RequestAQuote_Page = productBundle.RequestAQuote_Page; this.Theme = productBundle.Theme; this.ThemeId = productBundle.ThemeId; this.ProductBundleDetailTemplate = productBundle.ProductBundleDetailTemplate; this.SummaryCaption = productBundle.SummaryCaption; this.SummaryHtml = productBundle.SummaryHtml; this.TopDescriptionCaption = productBundle.TopDescriptionCaption; this.TopDescriptionHtml = productBundle.TopDescriptionHtml; this.TopLinkHref = productBundle.TopLinkHref; this.TopLinkLabel = productBundle.TopLinkLabel; this.BottomDescriptionCaption = productBundle.BottomDescriptionCaption; this.BottomDescriptionHtml = productBundle.BottomDescriptionHtml; this.BottomLinkHref = productBundle.BottomLinkHref; this.BottomLinkLabel = productBundle.BottomLinkLabel; this.FooterHtml = productBundle.FooterHtml; this.ProductTypeSingle = productBundle.ProductTypeSingle; this.ProductTypePlural = productBundle.ProductTypePlural; }
public void UpdateProductBundle(ProductBundle productBundle) { this.ProductBundle = productBundle; this.Category = productBundle.Category; }
protected ActionResult ViewBundle(ProductBundle bundle) { if (bundle == null) { throw new ApplicationException("Product Bundle is null, be sure bundle is set before calling ViewBundle"); } /// get current catalog item CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogByName(User.IsRegistered()), CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, bundle.Category, null, bundle, null); if (bundle.Theme != null) { ViewData.Theme(bundle.Theme); } else if (bundle.Category.Theme != null) { ViewData.Theme(bundle.Category.Theme); } return View("ViewBundle", this.LayoutNameForCatalog, model); }
protected void SetMetaTags(ProductBundle bundle) { StoreFrontConfiguration config = CurrentStoreFrontConfigOrThrow; _metaDescriptionOverride = bundle.MetaDescriptionOrSystemDefault(config); _metaKeywordsOverride = bundle.MetaKeywordsOrSystemDefault(config); }
/// <summary> /// Renders a bundle partial to display the bundle in a list of bundles for the current category /// </summary> /// <param name="htmlHelper"></param> /// <param name="bundle"></param> public static void RenderCatalogBundleForListPartial(this HtmlHelper<CatalogViewModel> htmlHelper, ProductBundle bundle) { CatalogViewModel viewModel = htmlHelper.ViewData.Model; ProductBundle oldValueProductBundle = htmlHelper.ViewData.Model.CurrentProductBundleOrNull; ViewDataDictionary<CatalogViewModel> newViewData = new ViewDataDictionary<CatalogViewModel>(htmlHelper.ViewData); newViewData.Model.CurrentProductBundleOrNull = bundle; string view = "_BundleForList_Partial"; htmlHelper.RenderCatalogPartialHelper(view, newViewData); htmlHelper.ViewData.Model.CurrentProductBundleOrNull = oldValueProductBundle; }
protected void RemoveItem(ProductBundle bundle, int productId) { if (bundle == null) { throw new ArgumentNullException("bundle"); } ProductBundleItem bundleItem = bundle.ProductBundleItems.SingleOrDefault(pbi => pbi.ProductId == productId); if (bundleItem == null) { AddUserMessage("Bundle Item not found", "The item you are trying to remove (Product Id: " + productId + ") is no longer in bundle '" + bundle.Name.ToHtml() + "' [" + bundle.ProductBundleId + "]", UserMessageType.Info); return; } else { string itemToRemoveName = bundleItem.Product.Name; int productBundleItemId = bundleItem.ProductBundleItemId; bool result = GStoreDb.ProductBundleItems.DeleteById(productBundleItemId); if (result) { GStoreDb.SaveChanges(); AddUserMessage("Bundle Item Removed", "Bundle item '" + itemToRemoveName.ToHtml() + "' [" + productBundleItemId + "] was removed from bundle '" + bundle.Name.ToHtml() + "' [" + bundle.ProductBundleId + "]", UserMessageType.Success); } else { AddUserMessage("Bundle Item Delete Error", "The item you are trying to remove '" + itemToRemoveName.ToHtml() + "' [" + productBundleItemId + "] could not be deleted from bundle '" + bundle.Name.ToHtml() + "' [" + bundle.ProductBundleId + "]", UserMessageType.Info); } } }
/// <summary> /// Uses productBundle.ProductBundleId and Product.ProductId to prevent dupes /// </summary> private static ProductBundleItem CreateSeedProductBundleItem(this IGstoreDb storeDb, ProductBundle productBundle, Product product, int order, StoreFront storeFront, int quantity, decimal baseUnitPrice, decimal baseListPrice, bool returnProductBundleItemIfExists, bool updateCategoryCounts) { if (productBundle.ProductBundleItems.Any(i => i.ProductId == product.ProductId)) { if (returnProductBundleItemIfExists) { return productBundle.ProductBundleItems.Single(i => i.ProductId == product.ProductId); } return null; } ProductBundleItem productBundleItem = storeDb.ProductBundleItems.Create(); productBundleItem.Client = storeFront.Client; productBundleItem.StoreFront = storeFront; productBundleItem.ProductBundleId = productBundle.ProductBundleId; productBundleItem.ProductId = product.ProductId; productBundleItem.BaseListPrice = baseListPrice; productBundleItem.BaseUnitPrice = baseUnitPrice; productBundleItem.Quantity = quantity; productBundleItem.Order = order; productBundleItem.ProductBundleId = productBundle.ProductBundleId; productBundleItem.IsPending = false; productBundleItem.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); productBundleItem.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeDb.ProductBundleItems.Add(productBundleItem); storeDb.SaveChangesEx(true, false, false, updateCategoryCounts); return productBundleItem; }