public void Save()
        {
            if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx"))
            {
                return;
            }

            int currentId;

            int.TryParse(Page.Request.QueryString["id"], out currentId);

            var currentDoc = new Document(currentId);

            // Get the current property type
            var propertyTypeId = ((DefaultData)this._data).PropertyId;

            var property = currentDoc.GenericProperties.FirstOrDefault(x => x.Id == propertyTypeId);

            var propertyAlias = property.PropertyType.Alias;
            // test if the property alias contains an shopalias

            var storeAlias = GetStoreAliasFromProperyAlias(propertyAlias);

            int newStock;

            int.TryParse(_txtStock.Text, out newStock);

            if (currentId != 0)
            {
                UWebshopStock.UpdateStock(currentId, newStock, false, storeAlias);
            }
        }
示例#2
0
        public static bool EditNodeProperties()
        {
            var editNodeId = HttpContext.Current.Request["editNodeId"];
            var storeAlias = HttpContext.Current.Request["storeAlias"];
            var sender     = HttpContext.Current.Request["Id"];

            if (!string.IsNullOrEmpty(editNodeId))
            {
                int nodeId;
                int.TryParse(editNodeId, out nodeId);

                if (nodeId != 0)
                {
                    bool publish = false;

                    //var contentService = ApplicationContext.Current.Services.ContentService;

                    var doc = IO.Container.Resolve <ICMSChangeContentService>().GetById(nodeId);

                    //var doc = new Document(nodeId);//contentService.GetById(nodeId);

                    foreach (var key in HttpContext.Current.Request.Form.AllKeys)
                    {
                        if (key != null && !key.StartsWith("ctl00$") && !key.StartsWith("body_TabView") && !key.StartsWith("__EVENT") && !key.StartsWith("__VIEWSTATE") && !key.StartsWith("__ASYNCPOST") && doc.HasProperty(key))
                        {
                            var value = HttpContext.Current.Request.Form[key];

                            if (!key.StartsWith("stock"))
                            {
                                if (!string.IsNullOrEmpty(value))
                                {
                                    doc.SetValue(key, value);

                                    //doc.SetValue(key, value);

                                    publish = true;
                                }
                            }
                            else
                            {
                                if (Product.IsAlias(doc.ContentTypeAlias) || ProductVariant.IsAlias(doc.ContentTypeAlias))
                                {
                                    int newStockInt;

                                    int.TryParse(value, out newStockInt);

                                    UWebshopStock.UpdateStock(nodeId, newStockInt, false, storeAlias);
                                }
                            }
                        }
                    }

                    if (publish)
                    {
                        //contentService.SaveAndPublish(doc, 0, true);
                        doc.SaveAndPublish();
                        //doc.Save();
                        //doc.Publish(new User(0));
                        BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("editContent.aspx?id=", sender));
                        return(true);
                    }
                }
            }

            return(false);
        }