public string AddComment(string comment, string itemUri, string userId, string userName) { string str = "0"; if (this.Logger.IsDebugEnabled) { this.Logger.DebugFormat("CommentRepository.AddComment Comment {0}, itemUri {1}", new object[] { comment, itemUri }); } try { WebServiceClient client = new WebServiceClient(); string str2 = this.Authenticate(""); TridionTcmUri tcmUri = UtilityHelper.GetTcmUri(itemUri); Coats.Crafts.CDS.Comment comment2 = new Coats.Crafts.CDS.Comment(); User user = new User { Id = userId, Name = userName }; comment = comment.Replace(Environment.NewLine, "#nl"); comment2.Content = comment; if (this.CommentModeration.ToLower() == "on") { comment2.Status = 0; } else { comment2.Status = 2; } comment2.ItemPublicationId = tcmUri.TcmPublicationID; comment2.ItemId = tcmUri.TcmItemId; comment2.ItemType = tcmUri.TcmItemType; comment2.ModeratedDate = new DateTime?(DateTime.UtcNow); comment2.LastModifiedDate = DateTime.UtcNow; comment2.CreationDate = DateTime.UtcNow; comment2.Score = 0; comment2.Moderator = ""; comment2.User = user; JavaScriptSerializer serializer = new JavaScriptSerializer(); str = client.UploadString("/Comments", "POST", "{d:" + serializer.Serialize(comment2) + "}"); } catch (Exception exception) { this.Logger.ErrorFormat("AddComment exception - {0}", new object[] { exception }); } return str; }
public void AddToComments(Comment comment) { base.AddObject("Comments", comment); }