Example #1
0
        public void VirtualCatalogWorkingTest()
        {
            var catalogController   = new CatalogModuleCatalogsController(GetCatalogService(), GetSearchService(), null, GetPropertyService(), GetPermissionService());
            var categoryController  = new CatalogModuleCategoriesController(GetSearchService(), GetCategoryService(), GetPropertyService(), GetCatalogService());
            var listEntryController = new CatalogModuleListEntryController(GetSearchService(), GetCategoryService(), GetItemService(), null);

            //Create virtual catalog
            var catalogResult = catalogController.GetNewVirtualCatalog() as OkNegotiatedContentResult <webModel.Catalog>;
            var vCatalog      = catalogResult.Content;

            vCatalog.Name = "vCatalog1";
            catalogController.Update(vCatalog);

            Assert.IsTrue(vCatalog.Virtual);

            //Create virtual category
            var categoryResult = categoryController.GetNewCategory(vCatalog.Id) as OkNegotiatedContentResult <webModel.Category>;
            var vCategory      = categoryResult.Content;

            vCatalog.Name = "vCategory";
            categoryController.Post(vCategory);

            Assert.IsTrue(vCategory.Virtual);

            //Link category to virtual category
            var link = new webModel.ListEntryLink {
                ListEntryId = "40773cd0-f2de-462f-9041-da742a274c38", ListEntryType = "Category", CatalogId = vCatalog.Id, CategoryId = vCategory.Id
            };

            listEntryController.CreateLinks(new webModel.ListEntryLink[] { link });


            //Check result
            var serachResult = listEntryController.ListItemsSearch(new webModel.ListEntrySearchCriteria
            {
                CatalogId     = vCatalog.Id,
                CategoryId    = vCategory.Id,
                ResponseGroup = webModel.ResponseGroup.WithCategories
            })
                               as OkNegotiatedContentResult <webModel.ListEntrySearchResult>;
            var listResult = serachResult.Content;

            Assert.IsTrue(listResult.ListEntries.Any());
            var category = listResult.ListEntries.First();

            Assert.IsTrue(category.Id == "40773cd0-f2de-462f-9041-da742a274c38");

            //Remove link
            //listEntryController.DeleteLinks(new webModel.ListEntryLink[] { link });
        }
Example #2
0
        public void WorkingWithCatalogPropertyTest()
        {
            var catalogController   = new CatalogModuleCatalogsController(GetCatalogService(), GetSearchService(), null, GetPropertyService(), GetPermissionService());
            var categoryController  = new CatalogModuleCategoriesController(GetSearchService(), GetCategoryService(), GetPropertyService(), GetCatalogService());
            var propertyController  = new CatalogModulePropertiesController(GetPropertyService(), GetCategoryService(), GetCatalogService());
            var productController   = new CatalogModuleProductsController(GetItemService(), GetPropertyService(), null, null, null);
            var listEntryController = new CatalogModuleListEntryController(GetSearchService(), GetCategoryService(), GetItemService(), null);

            //var propertyResult = propertyController.GetNewCatalogProperty("Apple") as OkNegotiatedContentResult<webModel.Property>;
            //var property = propertyResult.Content;

            //property.Name = "CLP_Test2";
            //property.Type = webModel.PropertyType.Product;

            //propertyController.Post(property);

            var catalogResult = catalogController.Get("Apple") as OkNegotiatedContentResult <webModel.Catalog>;
            var catalog       = catalogResult.Content;

            catalog.Properties[0].Values.Add(new webModel.PropertyValue {
                Value = "sssss", ValueType = PropertyValueType.ShortText
            });
            catalogController.Update(catalog);

            var serachResult = listEntryController.ListItemsSearch(new webModel.ListEntrySearchCriteria
            {
                CatalogId     = "Apple",
                CategoryId    = "186d61d8-d843-4675-9f77-ec5ef603fda3",
                ResponseGroup = webModel.ResponseGroup.Full
            })
                               as OkNegotiatedContentResult <webModel.ListEntrySearchResult>;
            var listResult = serachResult.Content;

            var listEntryProduct = listResult.ListEntries.OfType <webModel.ListEntryProduct>().FirstOrDefault();
            var product          = (productController.Get(listEntryProduct.Id) as OkNegotiatedContentResult <webModel.Product>).Content;
        }