Example #1
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            List <string> lstNamesProducts = Session.lstNamesProducts;

            string valuePrice = "";
            string valueKg    = "";

            string token = Session.Token;

            var idPurchaseRequest = Session.id;

            var findByIdPurchaseRequest = VirtualFairIntegration.FindByIdPurchaseRequest(token, idPurchaseRequest);

            //Peso ofrecido Kg

            List <string> lstIdProducts = new List <string>();

            int countId = 0;

            foreach (var item1 in findByIdPurchaseRequest.purchaseRequestProducts)
            {
                //Session.idProduct = item1.id;

                lstIdProducts.Add(item1.id.ToString());
            }

            var purchaseRequestProducers = new List <dynamic>();

            foreach (var item in lstNamesProducts)
            {
                valueKg    = String.Concat("nudPesoOfrecido", item);
                valuePrice = String.Concat("nudValor", item);

                Control ctrl  = this.Controls.Find(valueKg.ToString(), true).FirstOrDefault();
                Control ctrl1 = this.Controls.Find(valuePrice.ToString(), true).FirstOrDefault();



                if (ctrl != null)
                {
                    if (ctrl is NumericUpDown)
                    {
                        dynamic       participate = new System.Dynamic.ExpandoObject();
                        NumericUpDown kg          = ctrl as NumericUpDown;
                        NumericUpDown price       = ctrl1 as NumericUpDown;

                        participate.idPurchaseRequestProduct = Convert.ToInt32(lstIdProducts[countId]);
                        countId++;
                        participate.idProducer = Convert.ToInt32(Session.IdProfile);
                        participate.weight     = kg.Value;
                        participate.price      = price.Value;

                        purchaseRequestProducers.Add(participate);
                    }
                }
            }

            var createMassive = VirtualFairIntegration.CreateMassiveProducer(token, purchaseRequestProducers);

            if (createMassive.statusCode == 201)
            {
                string text  = createMassive.message;
                string title = "InformaciĆ³n";
                MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Information);


                var salesProcesses = new SalesProcesses();

                salesProcesses.Show();

                this.Close();
            }
            else
            {
            }
        }