public BeforeSyncCategory(BeforeSyncCategory parentSyncCat, category category) { Childs = new List<BeforeSyncCategory>(); Products = new List<BeforeSyncProduct>(); Id = (int)category.id; Title = category.name[0].Value; Base = category; Parent = parentSyncCat; if (parentSyncCat != null) parentSyncCat.Childs.Add(this); }
public BeforeSyncCatNode(BeforeSyncCategory @base) { Base = @base; }
public BeforeSyncProduct(BeforeSyncCategory beforeSyncCategory, product product) { Id = (int)product.id; Title = product.name[0].Value; Base = product; Category = beforeSyncCategory; beforeSyncCategory.Products.Add(this); }
private void Save(BeforeSyncCategory category) { if (!category.Checked) { CategoryFactory.Delete(category.Base); } foreach (var product in category.Products) { Save(product); } foreach (var child in category.Childs) { Save(child); } }
private BeforeSyncCategory BuildTree(BeforeSyncCategory parentSyncCat, category category) { var beforeSyncCategory = new BeforeSyncCategory(parentSyncCat, category); var products = StoreProducts.Where(p => p.id_category_default == category.id).ToList(); foreach (product product in products) { var beforeSyncProduct = new BeforeSyncProduct(beforeSyncCategory, product); } var childCategories = StoreCategories.Where(c => c.id_parent == category.id).ToList(); foreach (category child in childCategories) { BuildTree(beforeSyncCategory, child); } return beforeSyncCategory; }