Example #1
0
        public PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form,
                                                 MerchantTribeApplication app, Catalog.Category containerCategory)
        {
            PartJsonResult result = new PartJsonResult();

            string action = form["partaction"];

            switch (action.ToLowerInvariant())
            {
            case "addpart":
                string       parttype = form["parttype"];
                IContentPart part     = PartFactory.Instantiate(System.Guid.NewGuid().ToString(), parttype, this);
                if (part != null)
                {
                    this.AddPart(part);
                    app.CatalogServices.Categories.Update(containerCategory);
                    result.ResultHtml = part.RenderForEdit(app, containerCategory);
                }
                break;

            case "resort":
                string        sortedIds = form["sortedIds[]"];
                string[]      ids       = sortedIds.Split(',');
                List <string> idList    = new List <string>();
                foreach (string s in ids)
                {
                    idList.Add(s.Trim().Replace("part", ""));
                }
                result.Success = this.SortParts(idList);
                app.CatalogServices.Categories.Update(containerCategory);
                break;
            }
            return(result);
        }
Example #2
0
        public string MovePart(string fromPart, string toPart, string partId,
                               List <string> sortedIds,
                               MerchantTribeApplication app,
                               MerchantTribe.Commerce.Catalog.Category baseCategory)
        {
            string       result = string.Empty;
            IContentPart toMove = FindPart(partId);

            RemovePart(partId);
            IContentPart destination = FindPart(toPart);

            if (destination is IColumn)
            {
                IColumn container = destination as IColumn;
                container.AddPart(toMove);
                container.SortParts(sortedIds);
                result = toMove.RenderForEdit(app, baseCategory);
            }
            return(result);
        }