Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "BlogID,Name,Parent,Order,Active")] WA_Blogs wa_blogs)
        {
            if (ModelState.IsValid)
            {
                WA_Blogs change = db.WA_Blogs.Find(wa_blogs.BlogID);
                change.Name   = wa_blogs.Name;
                change.Parent = wa_blogs.Parent;
                change.Active = wa_blogs.Active;

                db.Entry(change).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(wa_blogs));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "UserID,UserName,Email,Password,DisplayName,Created,Modified,Avatar,LastLogin,IPLast,IPCreated")] WA_Users wa_users, HttpPostedFileBase filebase)
 {
     if (ModelState.IsValid)
     {
         if (Request.Files.Count > 0 || !String.IsNullOrEmpty(Request.Files[0].FileName))
         {
             string path       = "~/Content/images/avatar";
             string pathToSave = Server.MapPath(path);
             string filename   = Path.GetFileName(Request.Files[0].FileName);
             Request.Files[0].SaveAs(Path.Combine(pathToSave, filename));
             wa_users.Avatar = filename;
         }
         db.Entry(wa_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(wa_users));
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "RoleID,RoleName,Description")] WA_Roles wa_roles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(wa_roles).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(wa_roles));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "CommentID,ContenComment,PostID,Author,Created,Parent")] WA_Comments wa_comments)
 {
     if (ModelState.IsValid)
     {
         db.Entry(wa_comments).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostID = new SelectList(db.WA_Posts, "PostID", "Title", wa_comments.PostID);
     ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_comments.Author);
     return(View(wa_comments));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "PostID,Author,IsLike")] WA_Likes wa_likes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(wa_likes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostID = new SelectList(db.WA_Posts, "PostID", "Title", wa_likes.PostID);
     ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_likes.Author);
     return(View(wa_likes));
 }
Ejemplo n.º 6
0
        public ActionResult QuickEdit([Bind(Include = "PostID,Title,Description,ContentPost,Active")] WA_Posts wa_posts, int[] Blogs, HttpPostedFileBase filebase)
        {
            if (ModelState.IsValid)
            {
                if (Blogs == null || Blogs.Count() == 0)
                {
                    return(View("Edit", wa_posts));
                }
                WA_Posts change = db.WA_Posts.Find(wa_posts.PostID);
                change.Title       = wa_posts.Title;
                change.Description = wa_posts.Description;
                change.ContentPost = wa_posts.ContentPost;
                change.Active      = wa_posts.Active;
                change.WA_Blogs    = new List <WA_Blogs>();

                //Save pic
                string path = "~/Content/images/thuvien";
                if (Request.Files[0] != null)
                {
                    string tg         = DateTime.Now.ToString("ddMMyyyy_");
                    string pathToSave = Server.MapPath(path);
                    string filename   = tg + Path.GetFileName(Request.Files[0].FileName);
                    change.Picture = Path.Combine(path, filename);
                    Request.Files[0].SaveAs(Path.Combine(pathToSave, filename));
                }

                foreach (var item in Blogs)
                {
                    change.WA_Blogs.Add(db.WA_Blogs.Find(item));
                }
                db.Entry(change).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_posts.Author);
            return(View("Edit", wa_posts));
        }