Beispiel #1
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));
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "idPersona,nbrPersona,idPaisNacimiento,idPaisResidencia,fchNacimiento,correo,foto,videoEntrevista")] Persona persona, IEnumerable <HttpPostedFileBase> files)
        {
            persona.idPersona = db.Pais.Where(x => x.idPais == persona.idPaisResidencia).First().Persona.Count() + 1;
            byte[] fileData = null;
            using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
            {
                fileData = binaryReader.ReadBytes(Request.Files[0].ContentLength);
            }
            byte[] xByte = fileData;
            using (var binaryReader = new BinaryReader(Request.Files[1].InputStream))
            {
                fileData = binaryReader.ReadBytes(Request.Files[1].ContentLength);
            }
            byte[]   xByteVid = fileData;
            Imagenes imageI   = new Imagenes();
            Videos   video    = new Videos();

            //byte[] xByteVid = (byte[])_imageConverter.ConvertTo(convert, typeof(byte[]));
            video.descripcion       = "Entrevista " + persona.nbrPersona + "";
            video.id                = db.Videos.Count() + 1;
            video.info_bytes        = xByteVid;
            imageI.id               = db.Imagenes.Count();
            imageI.descripcion      = "" + persona.nbrPersona + "";
            imageI.info_bytes       = xByte;
            persona.foto            = imageI.id;
            persona.videoEntrevista = video.id;
            if (ModelState.IsValid)
            {
                db.Imagenes.Add(imageI);
                db.Videos.Add(video);
                TransactionSingletone.UploadPerson(persona);
                return(RedirectToAction("Index"));
            }

            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  = db.Videos.Where(x => x.id == 1).First().info_bytes;
            return(View(persona));
        }
Beispiel #4
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"));
        }
Beispiel #5
0
 public ActionResult CancelTransaction()
 {
     TransactionSingletone.SendRollback();
     db = TransactionSingletone.db;
     return(RedirectToAction("Index"));
 }
Beispiel #6
0
 public ActionResult ReloadTable()
 {
     TransactionSingletone.SendCommit();
     db = TransactionSingletone.db;
     return(RedirectToAction("Index"));
 }