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); }
public bool RemovePart(string id) { if (id == this.Id) { return(false); } IContentPart toRemove = null; foreach (IContentPart p in this.Parts) { if (p.Id == id) { toRemove = p; break; } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; bool result = container.RemovePart(id); if (result) { return(result); } } } if (toRemove != null) { this.Parts.Remove(toRemove); } return(true); }
public IContentPart FindPart(string partId) { if (partId == this.Id) { return(this); } foreach (IContentPart p in this.Parts) { if (p.Id == partId) { return(p); } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; IContentPart result = container.FindPart(partId); if (result != null) { return(result); } } } return(null); }
public bool RemovePart(string partId) { foreach (Column c in this._Columns) { IContentPart toRemove = null; foreach (IContentPart p in c.Parts) { if (p.Id == partId) { toRemove = p; break; } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; bool result = container.RemovePart(partId); if (result) { return(true); } } } if (toRemove != null) { c.Parts.Remove(toRemove); return(true); } } return(false); }
private void ImportPart(string xml) { XElement x = XElement.Parse(xml, LoadOptions.None); string id = Xml.Parse(x, "id"); string typecode = Xml.Parse(x, "typecode"); IContentPart p = PartFactory.Instantiate(id, typecode, this); p.DeserializeFromXml(xml); this.AddPart(p); }
public bool AddPart(IContentPart part) { if (this.Size < part.MinimumSize()) { return(false); } part.SetContainer(this); _Parts.Add(part); return(true); }
public bool AddPart(IContentPart part) { if (this.Size < part.MinimumSize()) { return false; } part.SetContainer(this); _Parts.Add(part); return true; }
public ActionResult Index(string pageid, string partid) { JsonResult result = new JsonResult(); MTApp.CurrentRequestContext.FlexPageId = pageid; MTApp.CurrentRequestContext.UrlHelper = this.Url; Category flexpage = MTApp.CatalogServices.Categories.Find(pageid); if (flexpage != null) { IContentPart part = flexpage.FindFlexPart(partid); result.Data = part.ProcessJsonRequest(Request.Form, MTApp, flexpage); } return(result); }
// Flex Page Stuff public IContentPart FindFlexPart(string partId) { IContentPart result = null; if (Versions.Count > 0) { if (partId == "0") { result = Versions[0].Root; } else { result = Versions[0].Root.FindPart(partId); } } return(result); }
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); }
public bool AddPart(IContentPart part) { Parts.Add(part); return(true); }
public bool AddPart(IContentPart part) { Parts.Add(part); return true; }