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);
        }
        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 "showeditor":
                result.IsFinishedEditing = false;
                result.Success           = true;
                result.ResultHtml        = BuildEditor();
                break;

            case "saveedit":

                string colsRequestedString = form["totalColumnsRequested"];
                int    columnsRequested    = this.Columns.Count;
                if (int.TryParse(colsRequestedString, out columnsRequested))
                {
                    this.SetNumberOfColumns(columnsRequested);
                }
                ParseColumnChanges(form);
                if (form["spacerabove"] == "on")
                {
                    this.SpacerAbove = true;
                }
                else
                {
                    this.SpacerAbove = false;
                }
                app.CatalogServices.Categories.Update(containerCategory);
                result.Success           = true;
                result.IsFinishedEditing = false;
                result.ResultHtml        = BuildEditor();
                break;

            case "canceledit":
                result.Success           = true;
                result.IsFinishedEditing = true;
                result.ResultHtml        = this.RenderForEdit(app, containerCategory);
                break;

            case "deletepart":
                containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);
                app.CatalogServices.Categories.Update(containerCategory);
                result.Success = true;
                break;
            }
            return(result);
        }
Example #3
0
        public PartJsonResult ProcessJsonRequest(System.Collections.Specialized.NameValueCollection form,
                                                 MerchantTribeApplication app, Catalog.Category containerCategory)
        {
            PartJsonResult result = new PartJsonResult();

            string action = form["partaction"];

            StringBuilder sb = new StringBuilder();

            switch (action.Trim().ToLowerInvariant())
            {
            case "showeditor":
                sb.Append("<textarea name=\"changedtext\" style=\"height:400px;width:675px;\">");
                sb.Append(this.RawHtml);
                sb.Append("</textarea><br />");
                sb.Append("<input type=\"hidden\" name=\"partaction\" class=\"editactionhidden\" value=\"saveedit\" />");
                sb.Append("<input type=\"submit\" name=\"canceleditbutton\" value=\"Close\">");
                sb.Append("<input type=\"submit\" name=\"savechanges\" value=\"Save Changes\">");
                result.IsFinishedEditing = false;
                result.Success           = true;
                result.ResultHtml        = sb.ToString();
                break;

            case "saveedit":
                this.RawHtml             = form["changedtext"];
                result.IsFinishedEditing = true;
                result.Success           = true;
                result.ResultHtml        = this.RenderForEdit(app, containerCategory);
                app.CatalogServices.Categories.Update(containerCategory);
                break;

            case "canceledit":
                result.Success           = true;
                result.IsFinishedEditing = true;
                result.ResultHtml        = this.RenderForEdit(app, containerCategory);
                break;

            case "deletepart":
                containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);
                app.CatalogServices.Categories.Update(containerCategory);
                break;
            }

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

            string action = form["partaction"];            

            StringBuilder sb = new StringBuilder();
          
            switch (action.Trim().ToLowerInvariant())
            {
                case "showeditor":                    
                    sb.Append("<textarea name=\"changedtext\" style=\"height:400px;width:675px;\">");
                    sb.Append(this.RawHtml);
                    sb.Append("</textarea><br />");
                    sb.Append("<input type=\"hidden\" name=\"partaction\" class=\"editactionhidden\" value=\"saveedit\" />");
                    sb.Append("<input type=\"submit\" name=\"canceleditbutton\" value=\"Close\">");
                    sb.Append("<input type=\"submit\" name=\"savechanges\" value=\"Save Changes\">");
                    result.IsFinishedEditing = false;
                    result.Success = true;
                    result.ResultHtml = sb.ToString();
                    break;
                case "saveedit":                    
                    this.RawHtml = form["changedtext"];
                    result.IsFinishedEditing = true;                    
                    result.Success = true;
                    result.ResultHtml = this.RenderForEdit(app, containerCategory);
                    app.CatalogServices.Categories.Update(containerCategory);
                    break;
                case "canceledit":
                    result.Success = true;
                    result.IsFinishedEditing = true;
                    result.ResultHtml = this.RenderForEdit(app, containerCategory);
                    break;
                case "deletepart":
                    containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);
                    app.CatalogServices.Categories.Update(containerCategory);
                    break;
            }

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

            string action = form["partaction"];

            StringBuilder sb = new StringBuilder();

            switch (action.Trim().ToLowerInvariant())
            {
            case "showeditor":
                result.IsFinishedEditing = false;
                result.Success           = true;
                result.ResultHtml        = BuildEditor(containerCategory, string.Empty, app);
                //result.ScriptFunction = initScript;
                break;

            case "saveedit":

                // Update from Form Here
                string editMessage = string.Empty;

                if (form["uploadedfilename"] != null)
                {
                    string uploadedname = form["uploadedfilename"];

                    if (uploadedname.Length > 0)
                    {
                        if (this.Images.Count < 1)
                        {
                            this.Images.Add(new ImageDisplayFile()
                            {
                                AltText = uploadedname, FileName = uploadedname, SortOrder = 0
                            });
                        }
                        else
                        {
                            this.Images[0].FileName = uploadedname;
                        }
                    }
                }

                if (this.Images.Count > 0)
                {
                    string altText = form["altfield"];
                    this.Images[0].AltText = altText;
                    editMessage            = "Changes Saved!";
                }
                else
                {
                    editMessage = "Upload an Image before Saving Changes!";
                }

                app.CatalogServices.Categories.Update(containerCategory);
                result.Success           = true;
                result.IsFinishedEditing = false;
                result.ResultHtml        = BuildEditor(containerCategory, editMessage, app);
                //result.ScriptFunction = initScript;
                break;

            case "canceledit":
                result.Success           = true;
                result.IsFinishedEditing = true;
                result.ResultHtml        = this.RenderForEdit(app, containerCategory);
                break;

            case "deletepart":
                containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);
                app.CatalogServices.Categories.Update(containerCategory);
                break;
            }

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

            string action = form["partaction"];
          
            StringBuilder sb = new StringBuilder();          
            switch (action.Trim().ToLowerInvariant())
            {
                case "showeditor":             
                    result.IsFinishedEditing = false;
                    result.Success = true;
                    result.ResultHtml = BuildEditor(containerCategory, string.Empty, app);
                    //result.ScriptFunction = initScript;
                    break;
                case "saveedit":  

                    // Update from Form Here                    
                    string editMessage = string.Empty;

                    if (form["uploadedfilename"] != null)
                    {
                        string uploadedname = form["uploadedfilename"];

                        if (uploadedname.Length > 0)
                        {
                            if (this.Images.Count < 1)
                            {
                                this.Images.Add(new ImageDisplayFile() { AltText = uploadedname, FileName = uploadedname, SortOrder = 0 });
                            }
                            else
                            {
                                this.Images[0].FileName = uploadedname;
                            }
                        }
                    }

                    if (this.Images.Count > 0)
                    {
                        string altText = form["altfield"];
                        this.Images[0].AltText = altText;
                        editMessage = "Changes Saved!";
                    }
                    else
                    {
                        editMessage = "Upload an Image before Saving Changes!";
                    }
                    
                    app.CatalogServices.Categories.Update(containerCategory);
                    result.Success = true;
                    result.IsFinishedEditing = false;
                    result.ResultHtml = BuildEditor(containerCategory, editMessage, app);
                    //result.ScriptFunction = initScript;
                    break;
                case "canceledit":
                    result.Success = true;
                    result.IsFinishedEditing = true;
                    result.ResultHtml = this.RenderForEdit(app, containerCategory);
                    break;
                case "deletepart":
                    containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);
                    app.CatalogServices.Categories.Update(containerCategory);
                    break;
            }

            return result;
        }
Example #7
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;
        }
        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 "showeditor":
                    result.IsFinishedEditing = false;
                    result.Success = true;
                    result.ResultHtml = BuildEditor();                                        
                    break;
                case "saveedit":

                    string colsRequestedString = form["totalColumnsRequested"];
                    int columnsRequested = this.Columns.Count;
                    if (int.TryParse(colsRequestedString, out columnsRequested))
                    {
                        this.SetNumberOfColumns(columnsRequested);
                    }
                    ParseColumnChanges(form);
                    if (form["spacerabove"] == "on")
                    {
                        this.SpacerAbove = true;
                    }
                    else
                    {
                        this.SpacerAbove = false;
                    }
                    app.CatalogServices.Categories.Update(containerCategory);
                    result.Success = true;
                    result.IsFinishedEditing = false;
                    result.ResultHtml = BuildEditor();
                    break;
                case "canceledit":
                    result.Success = true;
                    result.IsFinishedEditing = true;
                    result.ResultHtml = this.RenderForEdit(app, containerCategory);
                    break;
                case "deletepart":
                    containerCategory.GetCurrentVersion().Root.RemovePart(this.Id);                    
                    app.CatalogServices.Categories.Update(containerCategory);
                    result.Success = true;
                    break;

            }
            return result;
        }