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 string AddRating(string ratingValue, string itemUri, string userId, string displayName) { if (this.Logger.IsDebugEnabled) { this.Logger.DebugFormat("CommentRepository.AddRating ratingValue {0}, itemUri {1}", new object[] { ratingValue, itemUri }); } string str = this.CheckRating(itemUri, userId, true); string str2 = "0"; if (str != "rated") { try { WebServiceClient client = new WebServiceClient(); TridionTcmUri tcmUri = UtilityHelper.GetTcmUri(itemUri); User user = new User { Id = userId, Name = displayName }; Rating rating = new Rating { CreationDate = DateTime.UtcNow, LastModifiedDate = DateTime.UtcNow, ItemPublicationId = tcmUri.TcmPublicationID, ItemId = tcmUri.TcmItemId, ItemType = tcmUri.TcmItemType, RatingValue = ratingValue.ToString(), User = user, Id = "0" }; JavaScriptSerializer serializer = new JavaScriptSerializer(); str2 = client.UploadString("/Ratings", "POST", "{d:" + serializer.Serialize(rating) + "}"); } catch (Exception exception) { this.Logger.ErrorFormat("AddRating exception - {0}", new object[] { exception }); } } return str2; }