//#endregion // new stuff

        public void CheckOnParentAndNode()
        {
            List <ContentReference> theList = new List <ContentReference>();
            var shirt        = _refConv.GetContentLink("Long Sleeve Shirt White Small_1");
            var noProdParent = _refConv.GetContentLink("PriceTest_1");
            var Pack         = _refConv.GetContentLink("SomePackage_1");
            var Prod         = _refConv.GetContentLink("Shirt-Long-Sleeve_1");
            var node         = _refConv.GetContentLink("Shirts_1");

            theList.Add(shirt);        // parent = node, ...typeId "Variation" ... no children
            theList.Add(noProdParent); // parent = node ...typeId "Variation" ... no children
            theList.Add(Pack);         // parent = node ...typeId "Package" ... no children
            theList.Add(Prod);         //parent = node...typeId ""...no children
            theList.Add(node);

            // check ...TypeId - string/int

            var rel = new NodeEntryRelation
            {
                // IsPrimary
                // TargetCatalog
            };

            var rel2 = new PackageEntry
            {
                //GroupName
                //Quantity
                //SortOrder
            };

            var stuff = _contentLoader.GetItems(theList, new LoaderOptions());

            foreach (var item in stuff)
            {
                var Parent = _contentLoader.Get <CatalogContentBase>(item.ParentLink);

                // new...
                var children = _contentLoader.GetChildren <CatalogContentBase>(item.ContentLink);

                var ii = item.GetOriginalType().Name; // "ShirtVariation" ... have FullName also

                if (item is EntryContentBase)         // use this, checks "the tree"
                {
                    var ParentPackages =              // Smashing on the node... of course - "Wrong base class"
                                         _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentPackages();

                    var ParentProducts =
                        _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentProducts();

                    var ParentEntries =
                        _contentLoader.Get <EntryContentBase>(item.ContentLink).GetParentEntries();

                    var ParentCategories =
                        _contentLoader.Get <EntryContentBase>(item.ContentLink).GetCategories();
                }
            }

            // Can do like this now, not tested yet
            //var children2 = _relationRepository.GetChildren<NodeEntryRelation>(parentLink);
        }
Exemple #2
0
        public void AddNodeEntryRelation(ContentReference child, ContentReference parent, bool isPrimary)
        {
            var nodeEntryRelation = new NodeEntryRelation()
            {
                IsPrimary = isPrimary,
                Child     = child,
                Parent    = parent
            };

            _relationRepository.UpdateRelation(nodeEntryRelation);
        }
        public ActionResult AddAssociation(string entryCode, string nodeCode)
        {
            var model = new NodeEntryRelation()
            {
                EntryCode = entryCode,
                NodeCode  = nodeCode,
                SortOrder = 0,
                IsPrimary = true // new in 11.2
            };

            var        json   = JsonConvert.SerializeObject(model);
            HttpClient client = GetHttpClient();
            var        result = client.PostAsync($"/episerverapi/commerce/entries/{entryCode}/nodeentryrelations",
                                                 new StringContent(json, Encoding.UTF8, "application/json")).Result;

            return(RedirectToAction("SingleEntry", "Home", new { Code = entryCode }));
        }
Exemple #4
0
 private string PutNodeEntryRelation()
 {
     try
     {
         var model = new NodeEntryRelation()
         {
             EntryCode = "Tops-Tunics-LongSleeve",
             NodeCode  = "Tops-Sweaters",
             SortOrder = 5
         };
         var json   = JsonConvert.SerializeObject(model);
         var xml    = SerializeObjectToXml(typeof(NodeEntryRelation), model);
         var result = Put("episerverapi/commerce/entries/Tops-Tunics-LongSleeve/nodeentryrelations/Tops-Sweaters", new StringContent(json, Encoding.UTF8, "application/json")).Result.Content.ReadAsStringAsync().Result;
         WriteTextFile(Path.Combine(_nodeEntryRelationOutputPath, "PutJson.txt"), result);
         result = Put("episerverapi/commerce/entries/Tops-Tunics-LongSleeve/nodeentryrelations/Tops-Sweaters", new StringContent(xml, Encoding.UTF8, "text/xml")).Result.Content.ReadAsStringAsync().Result;
         WriteTextFile(Path.Combine(_nodeEntryRelationOutputPath, "PutXml.xml"), result);
         return("Put entry node entry relation complete.....");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }