Exemple #1
0
        public JsonResult Subida_Imagenes_Galeria(IEnumerable <HttpPostedFileBase> imagenes, string titulo, string autor, Guid id_galeriaAsociada)
        {
            //más informacion sobre el plugin para subir imagenes http://plugins.krajee.com/file-input-ajax-demo/1 // se utiliza ajax
            Galeria galeria = db.Galerias.Find(id_galeriaAsociada);


            foreach (var imagen in imagenes)
            {
                Fotos_galeria fotos_galeria = new Fotos_galeria
                {
                    Fotos_galeriaID = Guid.NewGuid()
                };
                fotos_galeria.Fotos_galeria_autor     = autor;
                fotos_galeria.Fotos_galeria_titulo    = titulo;
                fotos_galeria.Fotos_galeria_imagenURL = funcionesUtiles.AgregarImagen_Servidor(imagen, "/img/Galeria/", this.Server);
                fotos_galeria.Id_Galeria          = galeria;
                fotos_galeria.Fotos_galeria_fecha = DateTime.Now;
                db.Fotos_Galerias.Add(fotos_galeria);
                db.SaveChanges();
            }

            //if (Directory.Exists(Server.MapPath("/img/Galeria/"+galeria.Galeria_titulo+"")))
            //{
            //    foreach(var imagen in imagenes)
            //    {
            //        Fotos_galeria fotos_galeria = new Fotos_galeria
            //        {
            //            Fotos_galeriaID = Guid.NewGuid()
            //        };
            //        fotos_galeria.Fotos_galeria_autor = autor;
            //        fotos_galeria.Fotos_galeria_titulo = titulo;
            //        fotos_galeria.Fotos_galeria_imagenURL = funcionesUtiles.AgregarImagen_Servidor(imagen, "/img/Galeria/" + galeria.Galeria_titulo + "/", this.Server);
            //        fotos_galeria.Id_Galeria = galeria;
            //        fotos_galeria.Fotos_galeria_fecha = DateTime.Now;
            //        db.Fotos_Galerias.Add(fotos_galeria);
            //        db.SaveChanges();
            //    }
            //}
            //else
            //{
            //    Directory.CreateDirectory(Server.MapPath("/img/Galeria/" + galeria.Galeria_titulo + ""));
            //    foreach (var imagen in imagenes)
            //    {
            //        Fotos_galeria fotos_galeria = new Fotos_galeria
            //        {
            //            Fotos_galeriaID = Guid.NewGuid()
            //        };
            //        fotos_galeria.Fotos_galeria_autor = autor;
            //        fotos_galeria.Fotos_galeria_titulo = titulo;
            //        fotos_galeria.Fotos_galeria_imagenURL = funcionesUtiles.AgregarImagen_Servidor(imagen, "/img/Galeria/" + galeria.Galeria_titulo + "/", this.Server);
            //        fotos_galeria.Id_Galeria = galeria;
            //        fotos_galeria.Fotos_galeria_fecha = DateTime.Now;
            //        db.Fotos_Galerias.Add(fotos_galeria);
            //        db.SaveChanges();
            //    }

            //}

            return(Json("file uploaded succesfully"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "Fotos_galeriaID,Fotos_galeria_titulo,Fotos_galeria_autor,Fotos_galeria_imagenURL")] Fotos_galeria fotos_galeria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fotos_galeria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fotos_galeria));
 }
Exemple #3
0
        // POST: Admin/Fotos_galeria/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create([Bind(Include = "Fotos_galeriaID,Fotos_galeria_titulo,Fotos_galeria_autor,Fotos_galeria_imagenURL")] Fotos_galeria fotos_galeria)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        fotos_galeria.Fotos_galeriaID = Guid.NewGuid();
        //        db.Fotos_Galerias.Add(fotos_galeria);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    return View(fotos_galeria);
        //}

        // GET: Admin/Fotos_galeria/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Fotos_galeria fotos_galeria = db.Fotos_Galerias.Find(id);

            if (fotos_galeria == null)
            {
                return(HttpNotFound());
            }
            return(View(fotos_galeria));
        }
Exemple #4
0
        // GET: Admin/Fotos_galeria/Delete/5
        public ActionResult DeleteConfirmed(Guid id, Guid id_asociado)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Fotos_galeria fotos_galeria = db.Fotos_Galerias.Find(id);

            if (fotos_galeria == null)
            {
                return(HttpNotFound());
            }
            funcionesUtiles.QuitarImagen_Servidor(fotos_galeria.Fotos_galeria_imagenURL, this.Server);
            db.Fotos_Galerias.Remove(fotos_galeria);
            db.SaveChanges();
            return(RedirectToAction("Create", new { id = id_asociado }));
        }