public void EditComment(String nickname, String password, WebComment editedComment) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } if (editedComment == null) { throw new ArgumentNullException("editedComment"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); if (!Enum.IsDefined(typeof(CommentType), editedComment.CommentType)) { throw new ArgumentException(String.Format(Resources.Argument_InvalidCommentType, editedComment.CommentType)); } var comment = new data.Comment(editedComment.ID); if (comment.MemberIDFrom != member.MemberID) { throw new ArgumentException(Resources.Argument_InvalidCommentEditor); } UpdateComment(comment, editedComment); }
private static data.Comment CreateComment(WebComment comment, Member member) { var inReplyToCommentID = comment.InReplyToCommentID; var inReplyToComment = inReplyToCommentID == 0 ? null : data.Comment.GetComment(inReplyToCommentID); var result = new data.Comment() { ObjectID = comment.ObjectID, MemberIDFrom = member.MemberID, Text = HttpUtility.HtmlEncode(comment.Text), DTCreated = DateTime.Now, IsDeleted = false, CommentType = comment.CommentType, WebCommentID = UniqueID.NewWebID(), Path = inReplyToComment == null ? "/" : String.Format("/{0}/", inReplyToComment.InReplyToCommentID), SentFromMobile = 1 }; result.Save(); result.ThreadNo = inReplyToComment == null ? result.CommentID : inReplyToComment.ThreadNo; result.InReplyToCommentID = inReplyToCommentID == 0 ? result.CommentID : inReplyToCommentID; result.Save(); try { IncrementCommentCount((CommentType)comment.CommentType, comment.ObjectID); } catch { } return(result); }
private static void MakeFriends(data.Comment comment) { Debug.Assert(comment != null, "comment != null"); if (comment.InReplyToCommentID == comment.CommentID) /* First-level comment. */ { MakeFriends(comment.MemberIDFrom, GetPotentialFriendId(comment)); } else /* 2nd-level comment. */ { var parentComment = data.Comment.GetComment(comment.InReplyToCommentID); MakeFriends(comment.MemberIDFrom, parentComment.MemberIDFrom); } }
private static WebComment CreateComment(data.Comment comment) { return(new WebComment() { CommentType = comment.CommentType, DTCreated = comment.DTCreated.ToTicksString(), ID = comment.CommentID, Nickname = new Member(comment.MemberIDFrom).NickName, Text = Text2Mobile.Filter(comment.Text ?? ""), InReplyToCommentID = comment.InReplyToCommentID, ObjectID = comment.ObjectID, ParentCommentID = ExtractParentCommentID(comment.Path) }); }
public void RemoveComment(String nickname, String password, Int32 commentID) { if (String.IsNullOrEmpty(nickname)) { throw new ArgumentNullException("nickname"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var member = Member.GetMemberViaNicknamePassword(nickname, password); var comment = new data.Comment(commentID); if (comment.MemberIDFrom != member.MemberID) { throw new ArgumentException(Resources.Argument_InvalidCommentRemover); } data.Comment.DeleteComment(comment.WebCommentID); }
private static void MarkAsFovorite(data.Comment comment) { Debug.Assert(comment != null, "comment != null"); switch (comment.CommentType) { case 1: case 2: { var favorite = new Favourite() { MemberID = comment.MemberIDFrom, TheFavouriteObjectID = comment.ObjectID, ObjectType = comment.CommentType, DTCreated = DateTime.Now }; favorite.SaveWithCheck(); break; } } }
private static Int32 GetPotentialFriendId(data.Comment comment) { Debug.Assert(comment != null, "comment != null"); switch (comment.CommentType) { case 1: /* Video */ return(new data.Video(comment.ObjectID).MemberID); case 2: /* Photo */ return(new data.Photo(comment.ObjectID).MemberID); case 3: /* Wall */ return(comment.ObjectID); case 6: /* Blog */ return(new data.BlogEntry(comment.ObjectID).MemberID); case 7: /* AskAFriend */ return(new data.AskAFriend(comment.ObjectID).MemberID); } return(0); }
/// <summary> /// Takes an prepopulated IDataReader and creates an array of Comments /// </summary> public static List<Comment> PopulateObject(IDataReader dr) { ColumnFieldList list = new ColumnFieldList(dr); List<Comment> arr = new List<Comment>(); Comment obj; while (dr.Read()) { obj = new Comment(); if (list.IsColumnPresent("CommentID")) { obj._commentID = (int)dr["CommentID"]; } if (list.IsColumnPresent("WebCommentID")) { obj._webCommentID = (string)dr["WebCommentID"]; } if (list.IsColumnPresent("ObjectID")) { obj._objectID = (int)dr["ObjectID"]; } if (list.IsColumnPresent("MemberIDFrom")) { obj._memberIDFrom = (int)dr["MemberIDFrom"]; } if (list.IsColumnPresent("InReplyToCommentID")) { obj._inReplyToCommentID = (int)dr["InReplyToCommentID"]; } if (list.IsColumnPresent("Text")) { obj._text = (string)dr["Text"]; } if (list.IsColumnPresent("IsDeleted")) { obj._isDeleted = (bool)dr["IsDeleted"]; } if (list.IsColumnPresent("Path")) { obj._path = (string)dr["Path"]; } if (list.IsColumnPresent("CommentType")) { obj._commentType = (int)dr["CommentType"]; } if (list.IsColumnPresent("ThreadNo")) { obj._threadNo = (int)dr["ThreadNo"]; } if (list.IsColumnPresent("DTCreated")) { obj._dTCreated = (DateTime)dr["DTCreated"]; } if (list.IsColumnPresent("SentFromMobile")) { obj._sentFromMobile = (int)dr["SentFromMobile"]; } arr.Add(obj); } dr.Close(); return arr; }
private static data.Comment CreateComment(WebComment comment, Member member) { var inReplyToCommentID = comment.InReplyToCommentID; var inReplyToComment = inReplyToCommentID == 0 ? null : data.Comment.GetComment(inReplyToCommentID); var result = new data.Comment() { ObjectID = comment.ObjectID, MemberIDFrom = member.MemberID, Text = HttpUtility.HtmlEncode(comment.Text), DTCreated = DateTime.Now, IsDeleted = false, CommentType = comment.CommentType, WebCommentID = UniqueID.NewWebID(), Path = inReplyToComment == null ? "/" : String.Format("/{0}/", inReplyToComment.InReplyToCommentID), SentFromMobile = 1 }; result.Save(); result.ThreadNo = inReplyToComment == null ? result.CommentID : inReplyToComment.ThreadNo; result.InReplyToCommentID = inReplyToCommentID == 0 ? result.CommentID : inReplyToCommentID; result.Save(); try { IncrementCommentCount((CommentType)comment.CommentType, comment.ObjectID); } catch { } return result; }
public void RemoveComment(String nickname, String password, Int32 commentID) { if (String.IsNullOrEmpty(nickname)) throw new ArgumentNullException("nickname"); if (String.IsNullOrEmpty(password)) throw new ArgumentNullException("password"); var member = Member.GetMemberViaNicknamePassword(nickname, password); var comment = new data.Comment(commentID); if (comment.MemberIDFrom != member.MemberID) throw new ArgumentException(Resources.Argument_InvalidCommentRemover); data.Comment.DeleteComment(comment.WebCommentID); }
public void EditComment(String nickname, String password, WebComment editedComment) { if (String.IsNullOrEmpty(nickname)) throw new ArgumentNullException("nickname"); if (String.IsNullOrEmpty(password)) throw new ArgumentNullException("password"); if (editedComment == null) throw new ArgumentNullException("editedComment"); var member = Member.GetMemberViaNicknamePassword(nickname, password); if (!Enum.IsDefined(typeof(CommentType), editedComment.CommentType)) throw new ArgumentException(String.Format(Resources.Argument_InvalidCommentType, editedComment.CommentType)); var comment = new data.Comment(editedComment.ID); if (comment.MemberIDFrom != member.MemberID) throw new ArgumentException(Resources.Argument_InvalidCommentEditor); UpdateComment(comment, editedComment); }
/// <summary> /// Takes an prepopulated IDataReader and creates an array of Comments /// </summary> public static List <Comment> PopulateCommentWithJoin(IDataReader dr) { ColumnFieldList list = new ColumnFieldList(dr); List <Comment> arr = new List <Comment>(); Comment obj; while (dr.Read()) { obj = new Comment(); if (list.IsColumnPresent("CommentID")) { obj._commentID = (int)dr["CommentID"]; } if (list.IsColumnPresent("WebCommentID")) { obj._webCommentID = (string)dr["WebCommentID"]; } if (list.IsColumnPresent("ObjectID")) { obj._objectID = (int)dr["ObjectID"]; } if (list.IsColumnPresent("MemberIDFrom")) { obj._memberIDFrom = (int)dr["MemberIDFrom"]; } if (list.IsColumnPresent("InReplyToCommentID")) { obj._inReplyToCommentID = (int)dr["InReplyToCommentID"]; } if (list.IsColumnPresent("Text")) { obj._text = (string)dr["Text"]; } if (list.IsColumnPresent("IsDeleted")) { obj._isDeleted = (bool)dr["IsDeleted"]; } if (list.IsColumnPresent("Path")) { obj._path = (string)dr["Path"]; } if (list.IsColumnPresent("CommentType")) { obj._commentType = (int)dr["CommentType"]; } if (list.IsColumnPresent("DTCreated")) { obj._dTCreated = (DateTime)dr["DTCreated"]; } if (list.IsColumnPresent("ThreadNo")) { obj._threadNo = (int)dr["ThreadNo"]; } if (list.IsColumnPresent("WebMemberID")) { obj.WebMemberID = (string)dr["WebMemberID"]; } if (list.IsColumnPresent("NickName")) { obj.NickName = (string)dr["NickName"]; } if (list.IsColumnPresent("PhotoUrl")) { obj.PhotoUrl = (string)dr["PhotoUrl"]; } arr.Add(obj); } dr.Close(); return(arr); }
private static void UpdateComment(data.Comment commentToUpdate, WebComment comment) { commentToUpdate.Text = HttpUtility.HtmlEncode(comment.Text); commentToUpdate.Save(); }