public static void DeleteSellableItem(string productId, string parentId, string parentName, string catalogName)
        {
            using (new SampleMethodScope())
            {
                var key       = productId.ToSellableItemKey(catalogName);
                var getResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.SellableItems.ByKey(key));
                getResult.Should().NotBeNull();

                var view = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.GetEntityView(parentId, "Details", "DeleteSellableItem", getResult.Id));
                view.Properties = new ObservableCollection <ViewProperty>
                {
                    view.Properties.First(p => p.Name.Equals("Version")),
                    new ViewProperty {
                        Name = "DeleteOption", Value = ""
                    },
                };

                var result = Proxy.DoCommand(EngineExtensions.AuthoringContainer.Value.DoAction(view));
                result.Messages.Should().NotContainErrors();

                getResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.SellableItems.ByKey($"{parentName},{productId.ToEntityName<SellableItem>()},"));
                // fix for odata - Fluent assertions causes an Odata exception when a null check fails.
                (getResult == null).Should().BeTrue($"The sellable item {productId} was not deleted.");
                ConsoleExtensions.WriteExpectedError();
            }
        }
        public static void DeleteCatalog(string catalogName)
        {
            var getCatalogResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.Catalogs.ByKey(catalogName));

            getCatalogResult.Should().NotBeNull();

            var view = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.GetEntityView(getCatalogResult.Id, "Details", "DeleteCatalog", getCatalogResult.Id));

            view.Properties = new ObservableCollection <ViewProperty>
            {
                new ViewProperty {
                    Name = "Version", Value = getCatalogResult.Version.ToString(), OriginalType = "System.Int32"
                },
            };

            var result = Proxy.DoCommand(EngineExtensions.AuthoringContainer.Value.DoAction(view));

            result.Messages.Should().NotContainMessageCode("error");
            result.Messages.Should().NotContainMessageCode("validationerror");

            RunPurgeCatalogsMinion();

            getCatalogResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.Catalogs.ByKey(catalogName));
            // fix for odata - Fluent assertions causes an Odata exception when a null check fails.
            (getCatalogResult == null).Should().BeTrue($"The catalog {catalogName} was not deleted");
            ConsoleExtensions.WriteExpectedError();
        }
        public static void DeleteCategoryIfExists(string categoryId)
        {
            var getCategoryResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.Categories.ByKey(categoryId));

            if (getCategoryResult != null)
            {
                DeleteCategory(categoryId);
            }
            else
            {
                ConsoleExtensions.WriteExpectedError();
            }
        }
        public static void DeleteSellableItemIfExists(string productId, string parentId, string parentName, string catalogName)
        {
            var key       = productId.ToSellableItemKey(catalogName);
            var getResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.SellableItems.ByKey(key));

            if (getResult != null)
            {
                DeleteSellableItem(productId, parentId, parentName, catalogName);
            }
            else
            {
                ConsoleExtensions.WriteExpectedError();
            }
        }
        public static void DeleteCategory(string categoryId)
        {
            using (new SampleMethodScope())
            {
                var getCategoryResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.Categories.ByKey(categoryId));
                getCategoryResult.Should().NotBeNull();

                var selectDeleteOptionView = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.GetEntityView(categoryId, "Details", "SelectCategoryDeleteOption", categoryId));
                selectDeleteOptionView.Properties = new ObservableCollection <ViewProperty>
                {
                    new ViewProperty {
                        Name = "Version", Value = getCategoryResult.Version.ToString(), OriginalType = "System.Int32"
                    },
                };

                var selectDeleteOptionResult = Proxy.DoCommand(EngineExtensions.AuthoringContainer.Value.DoAction(selectDeleteOptionView));
                selectDeleteOptionResult.Messages.Should().NotContainErrors();

                var view = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.GetEntityView(getCategoryResult.Id, "Details", "DeleteCategory", getCategoryResult.Id));
                view.Properties = new ObservableCollection <ViewProperty>
                {
                    new ViewProperty {
                        Name = "Version", Value = (getCategoryResult.Version + 1).ToString(), OriginalType = "System.Int32"
                    },
                };

                var result = Proxy.DoCommand(EngineExtensions.AuthoringContainer.Value.DoAction(view));
                result.Messages.Should().NotContainErrors();

                RunPurgeCategoriesMinion();

                getCategoryResult = Proxy.GetValue(EngineExtensions.AuthoringContainer.Value.Categories.ByKey(categoryId));
                // fix for odata - Fluent assertions causes an Odata exception when a null check fails.
                (getCategoryResult == null).Should().BeTrue($"The category {categoryId} was not deleted");
                ConsoleExtensions.WriteExpectedError();
            }
        }