Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(sbyte id)
        {
            integrante integrante = db.integrante.Find(id);

            db.integrante.Remove(integrante);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        // GET: integrantes/Edit/5
        public ActionResult Edit(sbyte?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            integrante integrante = db.integrante.Find(id);

            if (integrante == null)
            {
                return(HttpNotFound());
            }
            return(View(integrante));
        }
Ejemplo n.º 3
0
        public ActionResult DelImage(sbyte?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            integrante integrante = db.integrante.Find(id);

            if (integrante == null)
            {
                return(HttpNotFound());
            }
            integrante.foto_integrante = null;
            db.Entry(integrante).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Edit", "integrantes", new { id = integrante.cd_integrante }));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "cd_integrante,tx_nome_integrante,tx_email_integrante,tx_nome_curto_integrante")] integrante integrante, HttpPostedFileBase upload_foto)
        {
            if (ModelState.IsValid)
            {
                if (db.integrante.Any(i => i.tx_nome_integrante == integrante.tx_nome_integrante))
                {
                    ModelState.AddModelError("integranteJaExiste", "Integrante já existe");
                }
                else
                {
                    if (upload_foto != null)
                    {
                        integrante.foto_integrante = new byte[upload_foto.ContentLength];
                        upload_foto.InputStream.Read(integrante.foto_integrante, 0, upload_foto.ContentLength);
                    }
                    db.integrante.Add(integrante);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(integrante));
        }
Ejemplo n.º 5
0
        public ActionResult GetImage(sbyte?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            integrante integrante = db.integrante.Find(id);

            if (integrante == null)
            {
                return(HttpNotFound());
            }
            byte[] imageData = integrante.foto_integrante;
            if (imageData != null && imageData.Length > 0)
            {
                //return File(imageData, "image/jpg");
                return(new FileStreamResult(new System.IO.MemoryStream(imageData), "image/jpeg"));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        public ActionResult Edit([Bind(Include = "cd_integrante,tx_nome_integrante,tx_email_integrante,tx_nome_curto_integrante")] integrante integrante, HttpPostedFileBase upload_foto = null)
        {
            if (ModelState.IsValid)
            {
                integrante integranteAntesDeSalvar = db.integrante.AsNoTracking().Where(i => i.cd_integrante == integrante.cd_integrante).First();
                byte[]     foto = integranteAntesDeSalvar.foto_integrante;
                integranteAntesDeSalvar = null;

                db.Entry(integrante).State = EntityState.Modified;

                if (upload_foto != null)
                {
                    integrante.foto_integrante = new byte[upload_foto.ContentLength];
                    upload_foto.InputStream.Read(integrante.foto_integrante, 0, upload_foto.ContentLength);
                }
                else
                {
                    integrante.foto_integrante = foto;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(integrante));
        }