// GET: Personas public ActionResult Index() { db = TransactionSingletone.db; decimal firstid = db.Pais.First().idPais; var persona = db.Persona.Include(p => p.Imagenes).Include(p => p.Pais).Include(p => p.Pais1).Where(p => p.idPaisResidencia == firstid); ViewBag.totalPaises = db.Pais.Count(); Pais pais = db.Pais.First(); ViewBag.idPais = pais.idPais; ViewBag.nombrePais = pais.nbrPais; ViewBag.area = pais.area; if (db.Persona.Where(x => x.idPersona == pais.idPresidenteActual).Count() > 0) { ViewBag.nombrePresi = "" + db.Persona.Where(x => x.idPersona == 1 && x.idPaisResidencia == pais.idPais).First().nbrPersona; } else { ViewBag.nombrePresi = "No hay"; } ViewBag.foto = db.Imagenes.Where(x => x.id == pais.fotoBandera).First().info_bytes; ViewBag.poblacion = db.Persona.Where(x => x.idPaisResidencia == pais.idPais).Count(); ViewBag.himno = db.Audios.Where(x => x.id == pais.himnoNacional).First().info_bytes; return(View(persona.ToList())); }
public ActionResult EstadisticaNacimiento() { RegistroCivilEntities db = TransactionSingletone.db; var lista = db.Database.SqlQuery <SP_Nacimientos_Result>("exec SP_Nacimientos"); return(View(lista.ToList())); }
public ActionResult EdadPromedio() { RegistroCivilEntities db = TransactionSingletone.db; var lista = db.Database.SqlQuery <SP_EdadPromedio1_Result>("exec SP_EdadPromedio"); return(View(lista.ToList())); }
// GET: Pais/Create public ActionResult CreatePais() { db = TransactionSingletone.db; ViewBag.fotoBandera = db.Imagenes.Where(x => x.id == 1).First().info_bytes; //ViewBag.himno = new SelectList(db.Audios, "id", "descripcion"); //ViewBag.fotoBandera = db.Imagenes.Where(x => x.id == 0); return(View()); }
public ActionResult PaisIndex(int id) { // TransactionSingletone.reloadDBContext(); db = TransactionSingletone.db; int cantidadPaises = db.Pais.Count(); if (id < 1) { id = 1; } if (id > db.Pais.Count()) { id = 1; } Pais pais = new Pais(); var persona = db.Persona.Include(p => p.Imagenes).Include(p => p.Pais).Include(p => p.Pais1).Where(p => p.idPaisResidencia == id); if (db.Pais.Where(x => x.idPais == id).Count() > 0) { pais = db.Pais.Where(x => x.idPais == id).First(); } else { return(PaisIndex(id + 1)); } ViewBag.totalPaises = db.Pais.Count(); ViewBag.nombrePais = pais.nbrPais; ViewBag.area = pais.area; if (db.Persona.Where(x => x.idPersona == pais.idPresidenteActual).Count() > 0) { ViewBag.nombrePresi = "" + db.Persona.Where(x => x.idPersona == pais.idPresidenteActual && x.idPaisResidencia == pais.idPais).First().nbrPersona + ""; } else { ViewBag.nombrePresi = "No hay"; } ViewBag.foto = db.Imagenes.Where(x => x.id == pais.fotoBandera).First().info_bytes; ViewBag.idPais = pais.idPais; ViewBag.poblacion = db.Persona.Where(x => x.idPaisResidencia == pais.idPais).Count(); ViewBag.himno = db.Audios.Where(x => x.id == pais.himnoNacional).First().info_bytes; return(View("Index", persona.ToList())); }
public ActionResult EditPais([Bind(Include = "idPais,nbrPais,area,poblacionActual,fotoBandera,himnoNacional,idPresidenteActual")] Pais pais) { if (ModelState.IsValid) { db = new RegistroCivilEntities(); TransactionSingletone.stopTransaction(); db.Pais.Attach(pais); var entity = db.Entry(pais); entity.State = EntityState.Modified; db.SaveChanges(); TransactionSingletone.ResetInstance(); return(RedirectToAction("Index")); db = TransactionSingletone.db; } ViewBag.himnoNacional = new SelectList(db.Audios, "id", "descripcion", pais.himnoNacional); ViewBag.fotoBandera = new SelectList(db.Imagenes, "id", "descripcion", pais.fotoBandera); ViewBag.idPresidenteActual = new SelectList(db.Persona.Where(p => p.idPaisNacimiento == pais.idPais), "idPersona", "nbrPersona", pais.idPresidenteActual); return(View(pais)); }
public ActionResult Edit([Bind(Include = "idPersona,nbrPersona,idPaisNacimiento,idPaisResidencia,fchNacimiento,correo,foto,videoEntrevista")] Persona persona) { if (ModelState.IsValid) { db = new RegistroCivilEntities(); TransactionSingletone.stopTransaction(); db.Persona.Attach(persona); var entity = db.Entry(persona); entity.State = EntityState.Modified; db.SaveChanges(); TransactionSingletone.ResetInstance(); return(RedirectToAction("Index")); db = TransactionSingletone.db; } ViewBag.foto = new SelectList(db.Imagenes, "id", "descripcion", persona.foto); ViewBag.idPaisNacimiento = new SelectList(db.Pais, "idPais", "nbrPais", persona.idPaisNacimiento); ViewBag.idPaisResidencia = new SelectList(db.Pais, "idPais", "nbrPais", persona.idPaisResidencia); ViewBag.videoEntrevista = new SelectList(db.Videos, "id", "descripcion", persona.videoEntrevista); return(View(persona)); }
public ActionResult CargarMediaDePrueba() { TransactionSingletone.stopTransaction(); db = new RegistroCivilEntities(); Videos video = db.Videos.Find(1); Imagenes imagen1 = db.Imagenes.Find(1); Imagenes imagen2 = db.Imagenes.Find(2); Audios audio = db.Audios.Find(1); byte[] videoByte = System.IO.File.ReadAllBytes(HostingEnvironment.ApplicationPhysicalPath + "\\Resources\\video.mp4"); byte[] imagen1Byte = System.IO.File.ReadAllBytes(HostingEnvironment.ApplicationPhysicalPath + "\\Resources\\BanderaDefault.jpeg"); byte[] imagen2Byte = System.IO.File.ReadAllBytes(HostingEnvironment.ApplicationPhysicalPath + "\\Resources\\PersonaDefault.jpeg"); byte[] audioByte = System.IO.File.ReadAllBytes(HostingEnvironment.ApplicationPhysicalPath + "\\Resources\\himno.mp3"); video.descripcion = "Default Interview"; video.info_bytes = videoByte; imagen1.descripcion = "Bandera Default Pais"; imagen1.info_bytes = imagen1Byte; imagen2.descripcion = "Foto de Perfil Default"; imagen2.info_bytes = imagen2Byte; audio.descripcion = "Audio Default"; audio.info_bytes = audioByte; try { //db.Videos.Attach(video); //db.Imagenes.Attach(imagen1); //db.Imagenes.Attach(imagen2); //db.Audios.Attach(audio); db.Entry(video).State = EntityState.Modified; db.Entry(imagen1).State = EntityState.Modified; db.Entry(imagen2).State = EntityState.Modified; db.Entry(audio).State = EntityState.Modified; db.SaveChanges(); TransactionSingletone.ResetInstance(); db = TransactionSingletone.db; } catch (Exception e) {} return(RedirectToAction("Index")); }
public ActionResult CancelTransaction() { TransactionSingletone.SendRollback(); db = TransactionSingletone.db; return(RedirectToAction("Index")); }
public ActionResult ReloadTable() { TransactionSingletone.SendCommit(); db = TransactionSingletone.db; return(RedirectToAction("Index")); }