public ActionResult DelPost(int id) { DB db = new DB(); Post posts = new Post(); posts = (from p in db.Posts where p.ID == id select p).FirstOrDefault(); db.Posts.Remove(posts); db.SaveChanges(); return Redirect("/Admin/ManagePost"); }
public ActionResult RevPost(int id) { DB db = new DB(); Post posts = new Post(); posts = (from p in db.Posts where p.ID == id select p).FirstOrDefault(); return Redirect("/Admin/ManagePost"); }
public ActionResult PublicPosts(string title, string content, string classify) { DB db = new DB(); Post posts = new Post(); posts.Title = title; posts.Content = content; posts.Classify = classify; posts.DateOfIssue = DateTime.Now; posts.Author = "尹逸朋"; db.Posts.Add(posts); int row = db.SaveChanges(); if (row > 0) { return Redirect("/Admin/Home/PublicPosts"); } else { return Redirect("/Admin/Error"); } }
public ActionResult PostMore(int id) { DB db = new DB(); List<Post> posts = new List<Post>(); List<vPost> vposts = new List<vPost>(); posts = (from p in db.Posts select p).ToList(); foreach (Post post in posts) { vPost vpost = new vPost(post); vposts.Add(vpost); } ViewBag.posts = vposts; List<Post> postList = new List<Post>(); postList = (from l in db.Posts orderby l.Browse descending select l).ToList(); ViewBag.postList = postList; Post post2 = new Post(); post2 = (from p in db.Posts where p.ID == id select p).FirstOrDefault(); post2.Browse++; db.SaveChanges(); ViewData["id"] = post2.ID; ViewData["title"] = post2.Title; ViewData["content"] = post2.Content; List<PostReply> postreply = new List<PostReply>(); postreply = (from p in db.PostReply where p.PostID == id select p).ToList(); ViewBag.postreply = postreply; return View(); }