Esempio n. 1
0
        // 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()));
        }
Esempio n. 2
0
        public ActionResult EstadisticaNacimiento()
        {
            RegistroCivilEntities db = TransactionSingletone.db;
            var lista = db.Database.SqlQuery <SP_Nacimientos_Result>("exec SP_Nacimientos");

            return(View(lista.ToList()));
        }
Esempio n. 3
0
        public ActionResult EdadPromedio()
        {
            RegistroCivilEntities db = TransactionSingletone.db;
            var lista = db.Database.SqlQuery <SP_EdadPromedio1_Result>("exec SP_EdadPromedio");

            return(View(lista.ToList()));
        }
Esempio n. 4
0
 // 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());
 }
Esempio n. 5
0
        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()));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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"));
        }
Esempio n. 9
0
 public ActionResult CancelTransaction()
 {
     TransactionSingletone.SendRollback();
     db = TransactionSingletone.db;
     return(RedirectToAction("Index"));
 }
Esempio n. 10
0
 public ActionResult ReloadTable()
 {
     TransactionSingletone.SendCommit();
     db = TransactionSingletone.db;
     return(RedirectToAction("Index"));
 }