public void addReport(E_reportes reporte) { using (var db = new Mapeo()) { db.reportes.Add(reporte); db.SaveChanges(); } }
protected void BT_GenerarReporte_Click(object sender, EventArgs e) { ClientScriptManager cm = this.ClientScript; string json = JsonConvert.SerializeObject(new DAO_Admin().getUserActivo().ToArray(), Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); string path = Server.MapPath("~\\View\\Reports\\Usuarios\\") + DateTime.Now.ToFileTime().ToString() + ".json"; System.IO.File.WriteAllText(path, json); cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('El resporte se ha generado');</script>"); E_reportes rep = new E_reportes(); rep.ReportDate = DateTime.Now; rep.Path = path; new DAO_Admin().addReport(rep); }