Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ResetImageTB resetImageTB = db.ResetImageTBs.Find(id);

            db.ResetImageTBs.Remove(resetImageTB);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        // GET: SMAdm/ResetImage/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResetImageTB resetImageTB = db.ResetImageTBs.Find(id);

            if (resetImageTB == null)
            {
                return(HttpNotFound());
            }
            return(View(resetImageTB));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ResetImageId,ResetPhoto")] ResetImageTB resetImageTB, HttpPostedFileBase Photo)
        {
            if (ModelState.IsValid)
            {
                if (Photo != null)
                {
                    WebImage img       = new WebImage(Photo.InputStream);
                    FileInfo photoInfo = new FileInfo(Photo.FileName);
                    string   newPhoto  = Guid.NewGuid().ToString() + photoInfo.Extension;

                    img.Save("~/Uploads/AboutPhoto/" + newPhoto);
                    resetImageTB.ResetPhoto = "/Uploads/AboutPhoto/" + newPhoto;
                }
                db.ResetImageTBs.Add(resetImageTB);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(resetImageTB));
        }
Ejemplo n.º 4
0
        public ActionResult Edit([Bind(Include = "ResetImageId,ResetPhoto")] ResetImageTB resetImageTB, int id, HttpPostedFileBase Photo)
        {
            if (ModelState.IsValid)
            {
                var resImg = db.ResetImageTBs.SingleOrDefault(m => m.ResetImageId == id);

                if (Photo != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(resImg.ResetPhoto)))
                    {
                        System.IO.File.Delete(Server.MapPath(resImg.ResetPhoto));
                    }
                    WebImage img       = new WebImage(Photo.InputStream);
                    FileInfo photoInfo = new FileInfo(Photo.FileName);
                    string   newPhoto  = Guid.NewGuid().ToString() + photoInfo.Extension;
                    img.Save("~/Uploads/AboutPhoto/" + newPhoto);
                    resImg.ResetPhoto = "/Uploads/AboutPhoto/" + newPhoto;
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(resetImageTB));
        }