private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int index = e.ColumnIndex; string str = dataGridView1.Rows[e.RowIndex].Cells["PostId"].Value.ToString(); int postId = Convert.ToInt32(str); postNow = PostServices.GetPostByPostId(postId); if (index == 7) //查看详情 { Form_postDetail form = new Form_postDetail(postNow); form.Show(); } else if (index == 8)//删除 { if (label_myPostsOrCollects.Text == "收藏") { int collectId = ManagePostsServices.GetCollectByUserIdAndPostId(user.UserId, postId); ManagePostsServices.DeleteCollect(collectId); MessageBox.Show("取消收藏成功!"); } else //我的帖子 { PostServices.DeletePost(user.UserId, postId); MessageBox.Show("删除成功!"); } } else if (index == 9)//修改 { } }
public ActionResult Delete(int id) { if (ModelState.IsValid) { using (var context = new PostServices()) { context.DeletePost(id); } } // Go to home page after a post has been created return(RedirectToAction("Index")); }
private void DeletePost(object sender, RoutedEventArgs e) { if (isAnyPosts) { bool t = postServices.DeletePost(currentPost.Id); if (t) { MessageWindow window = new MessageWindow("Done"); window.Show(); } else { MessageWindow window = new MessageWindow("Ooops some problem"); window.Show(); } } }
public ActionResult DeletePost(int PostID) { Post post = _postServices.GetPost(PostID); int threadID = post.ThreadID; int forumID = post.Thread.ForumID; if (post.Thread.FirstPost.PostID == PostID) { _threadServices.DeleteThread(post.ThreadID); SetSuccess("Thread deleted"); return RedirectToAction("ViewForum", "Board", new { ForumID = forumID }); } else { _postServices.DeletePost(PostID); SetSuccess("Post deleted"); return RedirectToAction("ViewThread", "Board", new { ThreadID = threadID }); } }
public void Delete(string id) { _postServices.DeletePost(id); }