Beispiel #1
0
		public void DeleteCommand(object o, CommandEventArgs e)
		{
			Usr.KickUserIfNotLoggedIn("Must be logged in to delete a post");
			if (e.CommandName.Equals("Delete"))
			{
				Comment CommentToDelete = new Comment(int.Parse(e.CommandArgument.ToString()));
				if (CurrentComment.ThreadK == CommentToDelete.ThreadK)
				{
					if (Usr.Current.CanDelete(CommentToDelete, CurrentThread, CurrentGroupUsr))
					{
						string redirect = CommentToDelete.Thread.UrlDiscussion();
						if (CommentToDelete.Thread.TotalComments == 1)
						{
							redirect = "/chat";
						}
						CommentToDelete.RegisterDelete(Usr.Current);
						CommentToDelete.DeleteAll(null);
						Response.Redirect(redirect);
					}
					else
					{
						throw new Exception("Can't delete");
					}
				}
			}
		}
Beispiel #2
0
		public bool DeleteComment(int commentK)
		{
			if (Usr.Current != null)
			{
				Comment comment = new Comment(commentK);
				if (Usr.Current.CanDelete(comment))
				{
					comment.RegisterDelete(Usr.Current);
					comment.DeleteAll(null);
					return true;
				}
			}
			return false;
		}