예제 #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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public bool AddPart(IContentPart part)
        {
            if (this.Size < part.MinimumSize())
            {
                return(false);
            }
            part.SetContainer(this);

            _Parts.Add(part);
            return(true);
        }
예제 #7
0
        public bool AddPart(IContentPart part)
        {
            if (this.Size < part.MinimumSize())
            {
                return false;
            }
            part.SetContainer(this);

            _Parts.Add(part);
            return true;
        }
예제 #8
0
        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);
        }
예제 #9
0
        // 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);
        }
예제 #10
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);
        }
예제 #11
0
 public bool AddPart(IContentPart part)
 {
     Parts.Add(part);
     return(true);
 }
예제 #12
0
 public bool AddPart(IContentPart part)
 {
     Parts.Add(part);
     return true;
 }