예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            poemTable poemtable = db.poemTables.Find(id);

            db.poemTables.Remove(poemtable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        // GET: /Poems/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            poemTable poemtable = db.poemTables.Find(id);

            if (poemtable == null)
            {
                return(HttpNotFound());
            }
            return(View(poemtable));
        }
예제 #3
0
        public ActionResult Edit(poemTable poemtable)
        {
            if (ModelState.IsValid)
            {
                String fileName  = Path.GetFileNameWithoutExtension(poemtable.ImageFile.FileName);
                String extension = Path.GetExtension(poemtable.ImageFile.FileName);
                fileName             = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                poemtable.poem_image = "~/Images/" + fileName;
                fileName             = Path.Combine(Server.MapPath("~/Images/"), fileName);
                poemtable.ImageFile.SaveAs(fileName);


                db.Entry(poemtable).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(poemtable));
        }