public DigitalDownloadFileError(Product product, string errorMessage) { if (product == null) { throw new ArgumentNullException("product"); } this.ErrorMessage = errorMessage; }
public ProductEditAdminViewModel(Product product, UserProfile userProfile) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (product == null) { throw new ArgumentNullException("product", "Product cannot be null"); } LoadValues(userProfile, product); }
public ProductEditAdminViewModel(Product product, UserProfile userProfile, string activeTab, bool isCreatePage = false, bool isEditPage = false, bool isDetailsPage = false, bool isDeletePage = false) { if (userProfile == null) { throw new ArgumentNullException("userProfile"); } if (product == null) { throw new ArgumentNullException("product", "Product cannot be null"); } this.IsCreatePage = isCreatePage; this.IsEditPage = isEditPage; this.IsDetailsPage = isDetailsPage; this.IsDeletePage = isDeletePage; this.ActiveTab = activeTab; LoadValues(userProfile, product); }
protected ActionResult ViewProduct(Product product) { if (product == null) { throw new ApplicationException("Product is null, be sure product is set before calling ViewProduct"); } /// get current catalog item CatalogViewModel model = new CatalogViewModel(CurrentStoreFrontOrThrow, CurrentStoreFrontOrThrow.CategoryTreeWhereActiveForCatalogByName(User.IsRegistered()), CurrentStoreFrontConfigOrThrow.CatalogPageInitialLevels, product.Category, product, null, null); if (product.Theme != null) { ViewData.Theme(product.Theme); } else if (product.Category.Theme != null) { ViewData.Theme(product.Category.Theme); } return View("ViewProduct", this.LayoutNameForCatalog, model); }
protected void SetMetaTags(Product product) { StoreFrontConfiguration config = CurrentStoreFrontConfigOrThrow; _metaDescriptionOverride = product.MetaDescriptionOrSystemDefault(config); _metaKeywordsOverride = product.MetaKeywordsOrSystemDefault(config); }
/// <summary> /// Renders a product partial to display the product in a list of products for the current category /// </summary> /// <param name="htmlHelper"></param> /// <param name="bundle"></param> public static void RenderCatalogProductForListPartial(this HtmlHelper<CatalogViewModel> htmlHelper, Product product) { CatalogViewModel viewModel = htmlHelper.ViewData.Model; Product oldValueCurrentProductOrNull = htmlHelper.ViewData.Model.CurrentProductOrNull; ViewDataDictionary<CatalogViewModel> newViewData = new ViewDataDictionary<CatalogViewModel>(htmlHelper.ViewData); newViewData.Model.CurrentProductOrNull = product; string view = "_ProductForList_Partial"; htmlHelper.RenderCatalogPartialHelper(view, newViewData); htmlHelper.ViewData.Model.CurrentProductOrNull = oldValueCurrentProductOrNull; }
protected void LoadValues(UserProfile userProfile, Product product) { if (product == null) { return; } this.IsActiveDirect = product.IsActiveDirect(); this.IsActiveBubble = product.IsActiveBubble(); this.Product = product; this.Client = product.Client; this.ClientId = (product.Client == null ? 0 : product.ClientId); this.CreateDateTimeUtc = product.CreateDateTimeUtc; this.CreatedBy = product.CreatedBy; this.CreatedBy_UserProfileId = product.CreatedBy_UserProfileId; this.EndDateTimeUtc = product.EndDateTimeUtc; this.ForRegisteredOnly = product.ForRegisteredOnly; this.ForAnonymousOnly = product.ForAnonymousOnly; this.IsPending = product.IsPending; this.Name = product.Name; this.UrlName = product.UrlName; this.ImageName = product.ImageName; this.ProductId = product.ProductId; this.Order = product.Order; this.Category = product.Category; this.ProductCategoryId = product.ProductCategoryId; this.StartDateTimeUtc = product.StartDateTimeUtc; this.StoreFront = product.StoreFront; this.StoreFrontId = product.StoreFrontId; this.UpdateDateTimeUtc = product.UpdateDateTimeUtc; this.UpdatedBy = product.UpdatedBy; this.UpdatedBy_UserProfileId = product.UpdatedBy_UserProfileId; this.MaxQuantityPerOrder = product.MaxQuantityPerOrder; this.MetaDescription = product.MetaDescription; this.MetaKeywords = product.MetaKeywords; this.AvailableForPurchase = product.AvailableForPurchase; this.RequestAQuote_Show = product.RequestAQuote_Show; this.RequestAQuote_Label = product.RequestAQuote_Label; this.RequestAQuote_PageId = product.RequestAQuote_PageId; this.RequestAQuote_Page = product.RequestAQuote_Page; this.BaseListPrice = product.BaseListPrice; this.BaseUnitPrice = product.BaseUnitPrice; this.Theme = product.Theme; this.ThemeId = product.ThemeId; this.ProductDetailTemplate = product.ProductDetailTemplate; this.DigitalDownload = product.DigitalDownload; this.DigitalDownloadFileName = product.DigitalDownloadFileName; this.SampleAudioCaption = product.SampleAudioCaption; this.SampleAudioFileName = product.SampleAudioFileName; this.SampleDownloadCaption = product.SampleDownloadCaption; this.SampleDownloadFileName = product.SampleDownloadFileName; this.SampleImageCaption = product.SampleImageCaption; this.SampleImageFileName = product.SampleImageFileName; this.SummaryCaption = product.SummaryCaption; this.SummaryHtml = product.SummaryHtml; this.TopDescriptionCaption = product.TopDescriptionCaption; this.TopDescriptionHtml = product.TopDescriptionHtml; this.TopLinkHref = product.TopLinkHref; this.TopLinkLabel = product.TopLinkLabel; this.BottomDescriptionCaption = product.BottomDescriptionCaption; this.BottomDescriptionHtml = product.BottomDescriptionHtml; this.BottomLinkHref = product.BottomLinkHref; this.BottomLinkLabel = product.BottomLinkLabel; this.FooterHtml = product.FooterHtml; }
public void UpdateProduct(Product product) { this.Product = product; this.Category = product.Category; }
/// <summary> /// Dupe-safe uses Discount.Code to prevent dupes /// </summary> private static Discount CreateSeedDiscount(this IGstoreDb storeDb, string code, decimal flatDiscount, Product freeProductOrNull, bool freeShipping, int maxUsesZeroForNoLimit, decimal minSubTotal, decimal percentOff, StoreFront storeFront) { if (storeFront.Discounts.Any(d => d.Code.ToLower() == code.ToLower())) { return null; } Discount record = storeDb.Discounts.Create(); record.Client = storeFront.Client; record.StoreFront = storeFront; record.Code = code; record.FlatDiscount = flatDiscount; record.FreeProduct = freeProductOrNull; record.FreeShipping = freeShipping; record.MaxUses = maxUsesZeroForNoLimit; record.MinSubtotal = minSubTotal; record.Order = (storeDb.Discounts.IsEmpty() ? 100 : storeDb.Discounts.All().Max(d => d.Order) + 10); record.PercentOff = percentOff; record.UseCount = 0; record.IsPending = false; record.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1); record.EndDateTimeUtc = DateTime.UtcNow.AddYears(100); storeDb.Discounts.Add(record); storeDb.SaveChangesEx(true, false, false, false); return record; }
/// <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; }