/// <summary> /// This is the init/copy method for this class. /// It should be used by the children classes in the constructor in order to correctly fill the properties of the object. /// </summary> /// <param name="objToCopy"></param> protected bool Init(SnippetComment objToCopy) { if (objToCopy == null) { return(false); } //save the values of the properties with private setters: CommentID = objToCopy.CommentID; SnippetID = objToCopy.SnippetID; CommenterID = objToCopy.CommenterID; CommenterFullName = objToCopy.CommenterFullName; Content = objToCopy.Content; SnippetCommentDate = objToCopy.SnippetCommentDate; DisqusPostId = objToCopy.DisqusPostId; DisqusAuthorUID = objToCopy.DisqusAuthorUID; //if the object to copy comes from a JSON deserialization, tke the arguments from the helper class: if (objToCopy is SnippetCommentComm) { SnippetCommentComm jsonObj = (SnippetCommentComm)objToCopy; CommentID = (objToCopy.CommentID > 0) ? objToCopy.CommentID : jsonObj.CommID; SnippetCommentDate = (objToCopy.CommentID > 0) ? objToCopy.SnippetCommentDate : jsonObj.CommSnippetCommentDate; } return(true); }
public override BaseEntity ToJSONEntity() { //set the values for properties with private setters using the helper class: SnippetCommentComm json = new SnippetCommentComm(); json.CommID = CommentID; json.CommSnippetCommentDate = SnippetCommentDate; json.Init(this); return(json); }