Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            News_images news_images = db.News_images.Find(id);

            db.News_images.Remove(news_images);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "id,image_path,image_name,image_volume")] News_images news_images)
 {
     if (ModelState.IsValid)
     {
         db.Entry(news_images).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(news_images));
 }
Ejemplo n.º 3
0
        // GET: Admin/News_images/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            News_images news_images = db.News_images.Find(id);

            if (news_images == null)
            {
                return(HttpNotFound());
            }
            return(View(news_images));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "id,image_path,image_name,image_volume")] News_images news_images, HttpPostedFileBase image_path)
        {
            if (ModelState.IsValid)
            {
                if (image_path.ContentType != "image/png" && image_path.ContentType != "image/jpeg" && image_path.ContentType != "image/gif")
                {
                    return(RedirectToAction("Create"));
                }

                string filename = DateTime.Now.ToString("ddMMyyyyHHmmssffff") + image_path.FileName;
                string path     = Path.Combine(Server.MapPath("~/Uploads"), filename);
                image_path.SaveAs(path);
                news_images.image_path = filename;
                db.News_images.Add(news_images);
                news_images.image_volume = image_path.ContentLength;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(news_images));
        }