Ejemplo n.º 1
0
        private void btnCreateJson_Click(object sender, EventArgs e)
        {
            PublicarVariacion publicarVariacion = new PublicarVariacion();

            publicarVariacion.title           = "Articulo automatizado";
            publicarVariacion.category_id     = "MLA370641";
            publicarVariacion.price           = 10000;
            publicarVariacion.currency_id     = "ARS";
            publicarVariacion.buying_mode     = "buy_it_now";
            publicarVariacion.listing_type_id = "bronze";
            publicarVariacion.condition       = "new";
            publicarVariacion.description     = "<div align =\"center\"><img src=\"https://trendsistemas.com/ml_images/descripcion_calzado_html.jpg\" alt=\"\" /></div>";
            publicarVariacion.variations      = new List <variations> {
                new variations()
                {
                    attribute_combinations = new List <attribute_combinations> {
                        new attribute_combinations()
                        {
                            id = "83000", value_id = "92028"
                        },
                        new attribute_combinations()
                        {
                            id = "73002", value_id = "82071"
                        }
                    },
                    picture_ids = new List <string> {
                        "https://trendsistemas.com/ml_images/050003.jpg", "https://trendsistemas.com/ml_images/050004.jpg"
                    },
                    seller_custom_field = "050001",
                    available_quantity  = 2,
                    price = 10
                },
                new variations()
                {
                    attribute_combinations = new List <attribute_combinations> {
                        new attribute_combinations()
                        {
                            id = "83000", value_id = "92028"
                        },
                        new attribute_combinations()
                        {
                            id = "73002", value_id = "82069"
                        }
                    },
                    picture_ids = new List <string> {
                        "https://trendsistemas.com/ml_images/050003.jpg", "https://trendsistemas.com/ml_images/050004.jpg"
                    },
                    seller_custom_field = "050001",
                    available_quantity  = 2,
                    price = 10
                }
            };
            string json = new JavaScriptSerializer().Serialize(publicarVariacion);
        }
Ejemplo n.º 2
0
        private string CreateJsonCopia()
        {
            DataSet           ds                = BL.MercadoLibreBLL.GetData();
            DataTable         tblColores        = ds.Tables[0];
            DataTable         tblTalles         = ds.Tables[1];
            PublicarVariacion publicarVariacion = new PublicarVariacion();

            publicarVariacion.title           = txtTitulo.Text;
            publicarVariacion.category_id     = categoria;
            publicarVariacion.price           = Convert.ToInt32(txtPrecio.Text);
            publicarVariacion.currency_id     = "ARS";
            publicarVariacion.buying_mode     = "buy_it_now";
            publicarVariacion.listing_type_id = "bronze";
            string condicion;

            if (rdNuevo.Checked)
            {
                condicion = "new";
            }
            else
            {
                condicion = "used";
            }
            publicarVariacion.condition   = condicion;
            publicarVariacion.description = "<div align =\"center\"><img src=\"https://trendsistemas.com/ml_images/descripcion_calzado_html.jpg\" alt=\"\" /></div>";
            var listVariaciones = new List <variations>();

            foreach (DataRow rowPublicar in tblPublicar.Rows)
            {
                variations variacion = new variations();
                variacion.attribute_combinations = new List <attribute_combinations>();

                var at = new attribute_combinations
                {
                    id       = rowPublicar[0].ToString(),
                    value_id = rowPublicar[0].ToString(),
                };
                variacion.Add(tc);
            }
            publicarVariacion.variations = listVariaciones;
            publicarVariacion.variations = new List <variations> {
                new variations()
                {
                    attribute_combinations = new List <attribute_combinations> {
                        new attribute_combinations()
                        {
                            id = "83000", value_id = "92028"
                        },
                        new attribute_combinations()
                        {
                            id = "73002", value_id = "82071"
                        }
                    },
                    picture_ids = new List <string> {
                        "https://trendsistemas.com/ml_images/050003.jpg", "https://trendsistemas.com/ml_images/050004.jpg"
                    },
                    seller_custom_field = "050001",
                    available_quantity  = 2,
                    price = 10
                },
                new variations()
                {
                    attribute_combinations = new List <attribute_combinations> {
                        new attribute_combinations()
                        {
                            id = "83000", value_id = "92028"
                        },
                        new attribute_combinations()
                        {
                            id = "73002", value_id = "82069"
                        }
                    },
                    picture_ids = new List <string> {
                        "https://trendsistemas.com/ml_images/050003.jpg", "https://trendsistemas.com/ml_images/050004.jpg"
                    },
                    seller_custom_field = "050001",
                    available_quantity  = 2,
                    price = 10
                }
            };
            string json = new JavaScriptSerializer().Serialize(publicarVariacion);

            return(json);
        }