/// <summary> /// Finalize the new Material /// </summary> public JObject commitMaterial(string MaterialDefinition) { JObject RetObj = new JObject(); JObject MaterialObj = CswConvert.ToJObject(MaterialDefinition); if (MaterialObj.HasValues) { JArray SizesArray = CswConvert.ToJArray(MaterialObj["sizeNodes"]); CswPrimaryKey MaterialId = new CswPrimaryKey(); MaterialId.FromString(CswConvert.ToString(MaterialObj["materialId"])); if (CswTools.IsPrimaryKey(MaterialId)) { CswNbtNode MaterialNode = _CswNbtResources.Nodes[MaterialId]; if (null != MaterialNode) { /* 1. Validate the new material and get its properties */ MaterialNode = _commitMaterialNode(MaterialObj); RetObj["createdmaterial"] = true; /* 2. Add the sizes */ if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers)) { SizesArray = _removeDuplicateSizes(SizesArray); _addMaterialSizes(SizesArray, MaterialNode); RetObj["sizescount"] = SizesArray.Count; } /* 3. Add landingpage data */ RetObj["landingpagedata"] = _getLandingPageData(MaterialNode); } } } return(RetObj); }
public CswNbtNodePropComments(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node) : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node) { _CommentSubField = ((CswNbtFieldTypeRuleComments)_FieldTypeRule).CommentSubField; // Associate subfields with methods on this object, for SetSubFieldValue() _SubFieldMethods.Add(_CommentSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >( () => CommentsJson, x => { if (null != x && false == String.IsNullOrEmpty(x.ToString())) { // not sure if this should be AddComment() CommentsJson = CswConvert.ToJArray(x); } })); }
} // ToJSON() public void ReadJson(JObject ParentObject) { if (null != ParentObject[ElemName_Data] && null != ParentObject[ElemName_Columns]) { Columns = new StringCollection(); JArray ColumnsAry = CswConvert.ToJArray(ParentObject[ElemName_Columns]); if (null != ColumnsAry) { foreach (string c in ColumnsAry.Values <string>()) { Columns.Add(c); } } // if( null != ColumnsAry ) JArray Data = CswConvert.ToJArray(ParentObject[ElemName_Data]); if (null != Data) { foreach (JObject ItemObj in Data) { Option o = new Option(); o.Key = CswConvert.ToString(ItemObj[ElemName_Key]); o.Label = CswConvert.ToString(ItemObj[ElemName_Label]); JArray Values = CswConvert.ToJArray(ItemObj["values"]); if (null != Values) { foreach (bool v in Values.Values <bool>()) { o.Values.Add(v); } // for( Int32 i = 0; i < ColumnNames.Count; i++ ) } // if( null != Values ) Options.Add(o); } // foreach( JObject ItemObj in Data ) } // if( null != Data ) } // if( null != ParentObject[ElemName_Data] && null != ParentObject[ElemName_Columns] ) } // ReadJson()