public async Task Delete(int tenantId, SubnavLink subNavlink = null)
        {
            var apiContext = new ApiContext(tenantId);
            var entityContainerResource = new EntityContainerResource(apiContext);
            var collection = await entityContainerResource.GetEntityContainersAsync(SubnavLinkEntityName, 200);

            var entityResource = new EntityResource(apiContext);

            if (subNavlink == null)
            {
                var appId = await GetAppId(apiContext);

                foreach (
                    var item in
                    collection.Items.Where(subnavLink => subnavLink.Item.ToObject <SubnavLink>().AppId.Equals(appId))
                    )
                {
                    await entityResource.DeleteEntityAsync(SubnavLinkEntityName, item.Id);
                }
            }
            else
            {
                if (subNavlink.ParentId == null || subNavlink.Path == null || !subNavlink.Path.Any())
                {
                    throw new Exception("ParentId and Path is required to delete a link");
                }
                var existing = collection.Items.FirstOrDefault(x => subNavlink.Path.SequenceEqual(x.Item.ToObject <SubnavLink>().Path) &&
                                                               (subNavlink.ParentId == x.Item.ToObject <SubnavLink>().ParentId || subNavlink.Location == x.Item.ToObject <SubnavLink>().Location));

                if (existing != null)
                {
                    await entityResource.DeleteEntityAsync(SubnavLinkEntityName, existing.Id);
                }
            }
        }
        private async Task <EntityContainer> GetExistingLink(IApiContext apiContext, SubnavLink subnavLink)
        {
            var entityContainerResource = new EntityContainerResource(apiContext);
            var collection = await entityContainerResource.GetEntityContainersAsync(SubnavLinkEntityName, 200);

            var existing = collection.Items.FirstOrDefault(x => FindMatch(x, subnavLink));

            return(existing);
        }