Пример #1
0
        private async Task DeleteAsync(Entity channelEntity, Entity deletedEntity)
        {
            switch (deletedEntity.EntityType.Id)
            {
            case "Resource":
                Guid resourceGuid = EpiserverEntryIdentifier.EntityIdToGuid(deletedEntity.Id);
                await _epiApi.DeleteResourceAsync(resourceGuid);

                break;

            case "Channel":
                await _epiApi.DeleteCatalogAsync(deletedEntity.Id);

                break;

            case "ChannelNode":
                await _epiApi.DeleteCatalogNodeAsync(deletedEntity, channelEntity.Id);

                break;

            case "Item":
                if ((_config.ItemsToSkus && _config.UseThreeLevelsInCommerce) || !_config.ItemsToSkus)
                {
                    await _epiApi.DeleteCatalogEntryAsync(deletedEntity);
                }

                if (_config.ItemsToSkus)
                {
                    var entitiesToDelete = new List <string>();

                    List <XElement> skuElements = _catalogElementFactory.GenerateSkuItemElemetsFromItem(deletedEntity);

                    foreach (XElement sku in skuElements)
                    {
                        XElement skuCodElement = sku.Element("Code");
                        if (skuCodElement != null)
                        {
                            entitiesToDelete.Add(skuCodElement.Value);
                        }
                    }

                    await _epiApi.DeleteSkusAsync(entitiesToDelete);
                }

                break;

            default:
                await _epiApi.DeleteCatalogEntryAsync(deletedEntity);

                break;
            }
        }