Пример #1
0
 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");
 }
Пример #2
0
 public ActionResult Register(string username , string password , string rpassword)
 {
     DB db = new DB();
     User user = new User();
     user.Name = username;
     user.Password = password;
     db.Users.Add(user);
     int row = db.SaveChanges();
     if (row > 0)
     {
         return Redirect("/Admin/Login");
     }
     else
     {
         return Redirect("/Admin/Error");
     }
 }
Пример #3
0
        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();
        }
Пример #4
0
 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");
         }
 }
Пример #5
0
        public ActionResult PostMore_reply(int id, string content)
        {
            DB db = new DB();
            PostReply postreply = new PostReply();
            postreply.PostID = id;
            postreply.ReplyContent = content;
            postreply.DateOfIssue = DateTime.Now;

            db.PostReply.Add(postreply);
            int row = db.SaveChanges();
            if (row > 0)
            {
                return Redirect("/Home/Index");
            }
            else
            {
                return Redirect("/Home/Error");
            }
        }