/// <summary>
 /// Create a new MP_Payments object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static MP_Payments CreateMP_Payments(global::System.Decimal id)
 {
     MP_Payments mP_Payments = new MP_Payments();
     mP_Payments.id = id;
     return mP_Payments;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the MP_Payments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMP_Payments(MP_Payments mP_Payments)
 {
     base.AddObject("MP_Payments", mP_Payments);
 }
        private void InserirMOvimentos(JObject t)
        {
            NSAADMEntities n;

            ConstruirEF cf = new ConstruirEF();
            n = (NSAADMEntities)cf.RecuperaEntity(Entities.MercadoLivre);

            decimal temp;
            Nullable<DateTime> tempd;

            foreach (var item in t)
            {

                string a = item.ToString();

                JToken j = t["response"];

                JToken s = j["results"];

                foreach (var i in s)
                {
                    JToken b = i["collection"];

                    if (VerificaPay(b) == false)
                    {

                        MP_Payments p = new MP_Payments();

                        p.id = (decimal)b["id"];
                        p.last_modified = (DateTime)b["last_modified"];
                        p.marketplace = (string)b["marketplace"];

                        p.installments = b["installments"].ToString();

                        Decimal.TryParse(b["marketplace_fee"].ToString(), out temp);
                        p.marketplace_fee = temp;

                        Decimal.TryParse(b["mercadopago_fee"].ToString(), out temp);
                        p.mercadopago_fee = temp;

                        Decimal.TryParse(b["net_received_amount"].ToString(), out temp);
                        p.net_received_amount = temp;

                        Decimal.TryParse(b["collector_id"].ToString(), out temp);
                        p.collector_id = temp;

                        Decimal.TryParse(b["currency_id"].ToString(), out temp);
                        p.currency_id = temp;

                        Decimal.TryParse(b["external_reference"].ToString(), out temp);
                        p.external_reference = temp;

                        Decimal.TryParse(b["total_paid_amount"].ToString(), out temp);
                        p.total_paid_amount = temp;

                        Decimal.TryParse(b["transaction_amount"].ToString(), out temp);
                        p.transaction_amount = temp;

                        Decimal.TryParse(b["account_money_amount"].ToString(), out temp);
                        p.account_money_amount = temp;

                        Decimal.TryParse(b["shipping_cost"].ToString(), out temp);
                        p.shipping_cost = temp;

                        p.operation_type = (string)b["operation_type"];
                        p.payment_type = (string)b["payment_type"];
                        p.reason = (string)b["reason"];
                        p.released = (string)b["released"];

                        p.site_id = (string)b["site_id"];
                        p.sponsor_id = (string)b["sponsor_id"];
                        p.status = (string)b["status"];
                        p.status_code = (string)b["status_code"];
                        p.status_detail = (string)b["status_detail"];

                        tempd = (Nullable<DateTime>)b["date_approved"];
                        p.date_approved = tempd;
                        p.date_created = (DateTime)b["date_created"];

                        tempd = (Nullable<DateTime>)b["money_release_date"];
                        p.money_release_date = tempd;
                        //p.money_release_date = (DateTime)b["money_release_date"];

                        //USUARIO
                        JToken user = b["payer"];
                        if (VerificaUser(user) == false)
                        {
                            ML_Usuario u = new ML_Usuario();
                            Decimal.TryParse(user["id"].ToString(), out temp);
                            u.id = temp;
                            u.nickname = (string)user["nickname"];
                            u.first_name = (string)user["first_name"];
                            u.last_name = (string)user["last_name"];
                            u.email = (string)user["email"];

                            JToken phone = user["phone"];
                            ML_Phone phon = new ML_Phone();
                            phon.area_code = (string)phone["area_code"];
                            phon.number = (string)phone["number"];
                            phon.extension = (string)phone["extension"];

                            u.ML_Phone.Add(phon);

                            n.ML_Usuario.AddObject(u);
                        }

                        n.AddToMP_Payments(p);

                        n.SaveChanges();
                    }
                }

            }
        }