Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Bid,Bttitle,Bcontent,BCategory,BDate,Bimagen")] Blog blog)
        {
            if (Request.Files["ImageData"].ContentLength > 0)
            {
                HttpPostedFileBase file       = Request.Files["ImageData"];
                byte[]             imageBytes = ConvertToBytes(file);
                blog.Bimagen = imageBytes;
            }
            else
            {
                using (var db = new blogEntities1())
                {
                    var blogDb = db.Blog.Find(blog.Bid);
                    blog.Bimagen = blogDb.Bimagen;
                }
            }
            if (ModelState.IsValid)
            {
                db.Entry(blog).State = EntityState.Modified;
                blog.Bactive         = true;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(blog));
        }
Ejemplo n.º 2
0
 public ActionResult Restore(int?id)
 {
     using (var db = new blogEntities1())
     {
         var user = db.Blog.Find(id);
         user.Bactive         = true;
         db.Entry(user).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     //db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 3
0
 public ActionResult DeleteConfirmed(int id)
 {/*
   * Blog blog = db.Blog.Find(id);
   * db.Blog.Remove(blog);
   * var search = from s in db.Blog select s;
   *   Blog bg = new Blog();
   * bg.Bactive = false;
   */
     using (var db = new blogEntities1())
     {
         var user = db.Blog.Find(id);
         user.Bactive         = false;
         db.Entry(user).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     //db.SaveChanges();
     return(RedirectToAction("Index"));
 }