private void DeleteOldUCommerceData() { var group = ProductCatalogGroup.SingleOrDefault(g => g.Name == "uCommerce.dk"); if (group != null) { // Delete products in group foreach ( var relation in CategoryProductRelation.All() .Where(x => group.ProductCatalogs.Contains(x.Category.ProductCatalog)) .ToList()) { var category = relation.Category; var product = relation.Product; category.RemoveProduct(product); product.Delete(); } // Delete catalogs foreach (var catalog in group.ProductCatalogs) { catalog.Deleted = true; } // Delete group itself group.Deleted = true; group.Save(); } }
private void UpdateStoreName(ProductCatalogGroup store, string value, ItemChanges changes) { if (ProductCatalogGroup.SingleOrDefault(x => x.Name == value) != null) { _loggingService.Log <ProductCatalogGroupTemplateBuilder>(string.Format("Failed to update store name for store. Store with name: {0} already exists.", value)); return; } store.Name = value; }
private ProductCatalogGroup CreateCatalogGroup() { var group = ProductCatalogGroup.SingleOrDefault(c => c.Name == _catalogGroupName) ?? new ProductCatalogGroupFactory().NewWithDefaults(_catalogGroupName); group.ProductReviewsRequireApproval = true; group.Deleted = false; group.CreateCustomersAsMembers = false; group.DomainId = null; group.Save(); group.OrderNumberSerie = GetDefaultOrderNumberSeries(); group.EmailProfile = GetDefaultEmailProfile(); group.Save(); return(group); }
public PipelineExecutionResult Execute(InitializeArgs subject) { if (ProductCatalogGroup.All().Any(x => x.Name == "avenue-clothing.com")) { return(PipelineExecutionResult.Success); } new ConfigurationInstaller().Configure(); new CatalogueInstaller("avenue-clothing.com", "Demo Store").Configure(); var group = ProductCatalogGroup.SingleOrDefault(g => g.Name == "uCommerce.dk"); if (group != null) { // Delete products in group foreach ( var relation in CategoryProductRelation.All() .Where(x => group.ProductCatalogs.Contains(x.Category.ProductCatalog)) .ToList()) { var category = relation.Category; var product = relation.Product; category.RemoveProduct(product); product.Delete(); } // Delete catalogs foreach (var catalog in group.ProductCatalogs) { catalog.Deleted = true; } // Delete group itself group.Deleted = true; group.Save(); } return(PipelineExecutionResult.Success); }
public IEnumerable <Product> Execute(TypeInfo input) { switch (input.TypeName) { case "Category": Category category = Category.SingleOrDefault(a => a.CategoryId == input.Id); return(Product.GetForCategory(category).ToList()); case "ProductCatalog": ProductCatalog productCatalog = ProductCatalog.SingleOrDefault(a => a.ProductCatalogId == input.Id); return(productCatalog.Categories.SelectMany(a => a.Products).Distinct().ToList()); case "ProductCatalogGroup": ProductCatalogGroup productCatalogGroup = ProductCatalogGroup.SingleOrDefault(a => a.ProductCatalogGroupId == input.Id); return (productCatalogGroup.ProductCatalogs.SelectMany(a => a.Categories).SelectMany(a => a.Products). Distinct().ToList()); default: throw new NotImplementedException( "Only Category, ProductCatalog and ProductCatalogGroup are allowed."); } }