//////////////////////////////////////////////////////////////////// // Manipulators //////////////////////////////////////////////////////////////////// /* * Copy an entire Attributes object. The "specified" flags are * assigned as true, and "declared" flags as false (except when * an attribute's type is not CDATA), * unless the object is an Attributes2 object. * In that case those flag values are all copied. * * @see AttributesImpl#setAttributes */ public void setAttributes(Attributes atts) { int length = atts.getLength(); base.setAttributes(atts); declared = new bool[length]; specified = new bool[length]; if (atts is Attributes2) { Attributes2 a2 = (Attributes2)atts; for (int i = 0; i < length; i++) { declared[i] = a2.isDeclared(i); specified[i] = a2.isSpecified(i); } } else { for (int i = 0; i < length; i++) { declared[i] = !"CDATA".equals(atts.getType(i)); specified[i] = true; } } }
public ActionResult Create(IFormCollection collection) { try { if (ModelState.IsValid) { Root product = new Root(); Item item = new Item(); Attributes attributes_1 = new Attributes(); Attributes attributes_2 = new Attributes(); Attributes attributes_3 = new Attributes(); Attributes1 attributes1 = new Attributes1(); Attributes2 attributes2 = new Attributes2(); attributes_1.attributeId = 338; attributes_1.attributeValueId = 6980; attributes_2.attributeId = 346; attributes_2.attributeValueId = 4290; attributes_3.attributeId = 47; attributes_3.attributeValueId = "COLOUR"; attributes1.attributeId = Convert.ToInt32(collection["items.attributeId"]); attributes1.attributeValueId = Convert.ToInt32(collection["items.attributeValueId"]); attributes2.attributeId = Convert.ToInt32(collection["items.attributeId"]); attributes2.customAttributeValue = collection["items.attributeId"]; Image image = new Image(); image.url = "https://www.sampleadress/path/folder/image_1.jpg"; item.barcode = collection["barcode"]; item.title = collection["title"]; item.productMainId = collection["productMainId"]; item.brandId = Convert.ToInt32(collection["brandId"]); item.categoryId = Convert.ToInt32(collection["categoryId"]); item.quantity = Convert.ToInt32(collection["quantity"]); item.stockCode = collection["stockCode"]; item.dimensionalWeight = Convert.ToInt32(collection["dimensionalWeight"]); item.description = collection["description"]; item.currencyType = collection["currencyType"]; item.listPrice = Convert.ToDouble(collection["listPrice"]); item.salePrice = Convert.ToDouble(collection["salePrice"]); item.vatRate = Convert.ToInt32(collection["vatRate"]); item.cargoCompanyId = Convert.ToInt32(collection["cargoCompanyId"]); item.shipmentAddressId = Convert.ToInt32(collection["shipmentAddressId"]); item.returningAddressId = Convert.ToInt32(collection["returningAddressId"]); List <Image> lstimage = new List <Image>(); lstimage.Add(image); item.images = lstimage; List <Attributes> lstAttributes = new List <Attributes>(); lstAttributes.Add(attributes_1); lstAttributes.Add(attributes_2); //List<Attributes1> lstAttributes1 = new List<Attributes1>(); //lstAttributes1.Add(attributes1); // item.attributes = lstAttributes1; //List<Attributes2> lstAttributes2 = new List<Attributes2>(); //lstAttributes2.Add(attributes2); //item.attributes = lstAttributes2; item.attributes = lstAttributes; List <Item> lstItem = new List <Item>(); lstItem.Add(item); product.items = lstItem; string productJson; productJson = System.Text.Json.JsonSerializer.Serialize(product); CallPostMethod(product).Wait(); return(View()); } else { StatusCodeResult res = this.StatusCode(400); return(res); } } catch (Exception ex) { return(View()); } }