protected void Page_Load(object sender, EventArgs e) { NSAADMEntities n; ConstruirEF cf = new ConstruirEF(); n = (NSAADMEntities)cf.RecuperaEntity(Entities.MercadoLivre); //***************************************** Request.InputStream.Position = 0; System.IO.StreamReader str = new System.IO.StreamReader(Request.InputStream); CallBackTemp c = new CallBackTemp(); c = JsonConvert.DeserializeObject<CallBackTemp>(str.ReadToEnd()); //***************************************** try { CallBackML teste = (from p in n.CallBackMLs where p.resource == c.resource select p).First(); } catch (Exception) { CallBackML call = new CallBackML(); call.received = c.received; call.resource = c.resource; call.sent = c.sent; call.topic = c.topic; call.userID = c.user_id; n.CallBackMLs.AddObject(call); n.SaveChanges(); if (c.topic == "questions") { ControlaMeli cm = new ControlaMeli(); ControlaPerguntas cp = new ControlaPerguntas(); cp.GravaPergunta(cm.RetonarQuestion(c.resource), cm.n); } if (c.topic == "orders") { ControlaMeli cm = new ControlaMeli(); ControlaOrdens co = new ControlaOrdens(); ConverterObjetoMLparaEF conv = new ConverterObjetoMLparaEF(); co.GravaOrdem(cm.RetornaOrder(c.resource),cm.n); } } }
protected void Button1_Click(object sender, EventArgs e) { ControlaMeli cm = new ControlaMeli(); ConverterObjetoMLparaEF conv = new ConverterObjetoMLparaEF(); var x = (from p in cm.n.CallBackMLs where p.topic == "questions" select p); foreach (CallBackML c in x.ToList()) { if (c.topic == "questions") { Question q = cm.RetonarQuestion(c.resource); ControlaPerguntas p = new ControlaPerguntas(); p.GravaPergunta(q, cm.n); } } }