protected virtual void LoadComments(CommentItem addedComment) { // Comments enabled and exist? if (CurrentEntry.DisableComments.Checked || ManagerFactory.CommentManagerInstance.GetCommentsCount() == 0) { if (CommentList != null) { CommentList.Visible = false; } } else { if (ListViewComments != null) { CommentItem[] comments = ManagerFactory.CommentManagerInstance.GetEntryComments(); //if a comment has been added but is not coming back yet (i.e. being indexed), fake it if (addedComment != null && comments.Count(comment => comment.ID == addedComment.ID) == 0) { List <CommentItem> newList = new List <CommentItem>(); newList.Add(addedComment); newList.AddRange(comments); comments = newList.ToArray(); } ListViewComments.DataSource = comments; ListViewComments.DataBind(); } } }
/// <summary> /// Convert json comment back to BE comment /// </summary> /// <param name="c">Json comment</param> /// <returns>Comment</returns> public static Comment SetComment(CommentItem c) { Comment item = (from p in Post.Posts from cmn in p.AllComments where cmn.Id == c.Id select cmn).FirstOrDefault(); if (c.IsPending) { item.IsApproved = false; item.IsSpam = false; } if (c.IsApproved) { item.IsApproved = true; item.IsSpam = false; } if (c.IsSpam) { item.IsApproved = false; item.IsSpam = true; } item.Email = c.Email; item.Author = c.Author; return(item); }
public async Task <IActionResult> Post([FromBody] CommentItem item) { var commentRepository = _unitOfWork.GetRepository <Comment>(); var postRepository = _unitOfWork.GetRepository <Post>(); try { var post = await postRepository.GetFirstOrDefaultAsync(predicate : m => m.Id == item.PostId); var newItem = new Comment() { Content = item.Content, CreateDate = DateTime.UtcNow, DisplayName = item.DisplayName, Ip = AspNetCoreHelper.GetRequestIP(), Posts = post, Email = item.Email, IsApproved = true, ParentId = item.ParentId, }; await commentRepository.InsertAsync(newItem); await _unitOfWork.SaveChangesAsync(); item.Id = newItem.Id; item.HasChildren = false; item.IsApproved = true; item.DateCreated = newItem.CreateDate.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture); return(Ok(item)); } catch (Exception ex) { return(NotFound()); } }
public void Process(PopulateScribanMailActionModelArgs args) { EntryItem entryItem = null; CommentItem commentItem = null; var dataItem = args.WorkflowPipelineArgs.DataItem; if (_templateManager.TemplateIsOrBasedOn(dataItem, _settings.EntryTemplateIds)) { entryItem = new EntryItem(args.WorkflowPipelineArgs.DataItem); } else if (_templateManager.TemplateIsOrBasedOn(dataItem, _settings.CommentTemplateIds)) { commentItem = new CommentItem(args.WorkflowPipelineArgs.DataItem); entryItem = _entryManager.GetBlogEntryItemByCommentUri(commentItem.InnerItem.Uri); } if (args.EntryItem == null && entryItem != null) { args.EntryItem = entryItem; } if (args.CommentItem == null && commentItem != null) { args.CommentItem = commentItem; } }
private void DeleteComment(CommentItem obj) { this.VM.DeleteComment(obj.Comment.cid); this.virtPanel.RemoveItem((IVirtualizable)obj); this._runningCommentsCount = this._runningCommentsCount - 1; this.KeepCommentsCountItemUpToDate(); }
void _postsList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { var comments = sender as ObservableCollection <MainViewModel.post_with_username_wrapper>; if (comments != null) { //start from new startindex for (int i = e.NewStartingIndex; i < comments.Count; i++) { MainViewModel.post_with_username_wrapper c = comments[i]; var newcom = new CommentItem(); newcom.UserImage.Background = new ImageBrush() { Stretch = Stretch.UniformToFill, ImageSource = Constants.ByteArrayToImageConverter.Convert(c.userImage) }; c.PropertyChanged += (s, a) => { newcom.UserImage.Background = new ImageBrush() { Stretch = Stretch.UniformToFill, ImageSource = Constants.ByteArrayToImageConverter.Convert(c.userImage) }; }; newcom.CommentText.Text = c.post.text; newcom.NameText.Text = c.post.name + " " + c.post.lastname; newcom.DateText.Text = " " + c.post.created_at.Date.ToString(); _mainpanel.Children.Add(newcom); } } }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { try { CommentItem item = new CommentItem(); item.Username = this.Username.Text; item.Comment = this.Comment.Text; item.CreatedAt = DateTime.Now; item.RegionCode = ViewModelLocator.MainStatic.CurrentSelectedRegionItem.Code.ToString(); ViewModelLocator.MainStatic.AddBox.IsOpen = false; if ((item.Username != "") && (item.Username != "")) { await CommentTable.InsertAsync(item); MessageDialog result = new MessageDialog("Комментарий успешно добавлен."); result.ShowAsync(); } else { MessageDialog result = new MessageDialog("Укажите ваше имя и текст комментария."); result.ShowAsync(); }; } catch { }; }
public async void Execute(CreateCommentCommand command) { if (command == null) { throw new ArgumentNullException("command"); } if (_repository == null) { throw new InvalidOperationException("Repository is not initialized."); } var instruction = await _repository.FindAsync(command.Id); var aggregate = new CommentItem (command.Id, command.AdaptivReconId, command.Reference, command.ReconStatus, command.Comments, command.Username, command.BusinessDate, command.CommentDate); if (instruction != null) { await _repository.UpdateAsync(Mapper.Map <CommentItem, MetaAdaptivReconComment>(aggregate)); } else { await _repository.AddAsync(Mapper.Map <CommentItem, MetaAdaptivReconComment>(aggregate)); } }
public CommentItem Add(CommentItem item) { return(new CommentItem() { Id = Guid.NewGuid() }); }
void AddButtonList() { foreach (Transform child in contentPanel.GetComponentsInChildren <Transform>()) { if (child.gameObject.name.Equals("CommentItem")) { Destroy(child.gameObject); } } if (tempResutl.Count > 0) { results.AddRange(tempResutl); } for (int i = 0; i < results.Count; i++) { Debug.Log(results); ParseObject obj = results[i]; ParseUser user = (ParseUser)obj["user"]; //Debug.Log(obj["stars"].GetType()); GameObject newobj; newobj = (GameObject)Instantiate(commentItemPrefab); newobj.transform.SetParent(contentPanel); newobj.transform.localScale = new Vector3(1f, 1f, 1f); newobj.name = "CommentItem"; CommentItem map = newobj.GetComponent <CommentItem>(); map.createRow((string)user["nickName"], obj.CreatedAt.ToString(), (string)obj["content"]); if (i == results.Count - 1) { loadMore = false; } } }
public async Task <ActionResult <CommentItem> > PostCommentItem(CommentItem item) { _context.CommentItems.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetCommentItem), new { id = item.Id }, item)); }
public override DataItem CreateData(UndoRedoManager undoRedo) { var comment = new CommentItem(this, undoRedo); comment.Value = Text; return(comment); }
private static void TestOthers(BuildDocumenter documenter, TestOptions options, ReferenceEngineSettings engineSettings) { if (tocType == CustomTocType.ReferenceRoot) { return; } //string libraryDir = Path.Combine(sampleDir, @"SampleTestLibraryCLR\"); //string outputDir = Path.Combine(libraryDir, @"Output\"); //string projectDoc = Path.Combine(outputDir, "Project.xml"); string sourceFile = @"F:\SandcastleAssist\Main\Samples\HelpersSamples.sln"; ReferenceVsNetSource vsSource = new ReferenceVsNetSource(); ReferenceVsNetItem vsItem = new ReferenceVsNetItem( new BuildFilePath(sourceFile)); //vsItem.XamlSyntax = false; vsItem.AddInclude("{41A48F1C-3E52-4995-B181-363EDBC02CA0}"); vsSource.Add(vsItem); CommentContent comments = vsSource.Comments; CommentItem projItem = new CommentItem("R:Project", CommentItemType.Project); projItem.Value.Add(new CommentPart("Summary of the project", CommentPartType.Summary)); comments.Add(projItem); CommentItem nsItem = new CommentItem("N:TestLibraryCLR", CommentItemType.Namespace); nsItem.Value.Add(new CommentPart("Summary of the namespace", CommentPartType.Summary)); comments.Add(nsItem); ReferenceGroup apiGroup = new ReferenceGroup( "Test CPP-CLR Library", Guid.NewGuid().ToString(), vsSource); apiGroup.RunningHeaderText = "Sandcastle Helpers: C++/CLR Library"; apiGroup.VersionType = ReferenceVersionType.AssemblyAndFile; if (engineSettings.RootNamespaceContainer) { apiGroup.RootNamespaceTitle = "Testing C++/CLR Library"; } //ReferenceContent apiContent = apiGroup.Content; //apiContent.FrameworkType = BuildFrameworkType.Framework20; //apiGroup.AddItem(projectDoc, null); //apiContent.AddItem(Path.Combine(outputDir, "SampleLibraryCLR.xml"), // Path.Combine(outputDir, "SampleLibraryCLR.dll")); //apiContent.AddDependency(Path.Combine(outputDir, "")); documenter.AddGroup(apiGroup); }
private void editCommentCallback(CommentItem commentItem) { commentItem.Comment.GroupId = this._gid; commentItem.Comment.TopicId = this._tid; ParametersRepository.SetParameterForId("EditDiscussionComment", (object)commentItem.Comment); ParametersRepository.SetParameterForId("CidToAuthorIdDict", (object)this.GetCidToAuthorDict()); Navigator.Current.NavigateToNewWallPost(Math.Abs(commentItem.Comment.owner_id), commentItem.Comment.owner_id < 0, 0, false, false, false); }
/// <summary> /// Проверяет еквивалентны ли два комментария. /// </summary> /// Описание входных параметров. /// <param name="first_comment">Первый комментарий для сравнения.</param> /// <param name="second_comment">Второй комментарий для сравнения.</param> private void AreEqualComments(CommentItem first_comment, CommentItem second_comment) { Assert.AreEqual(first_comment.Id, second_comment.Id); Assert.AreEqual(first_comment.AddDate, second_comment.AddDate); Assert.AreEqual(first_comment.PersonId, second_comment.PersonId); Assert.AreEqual(first_comment.Text, second_comment.Text); Assert.AreEqual(first_comment.TaskId, second_comment.TaskId); }
public void ImplicitOperatorFromItem_NullItem_ReturnsNull() { // arrange, act CommentItem commentItem = (Item)null; // assert Assert.That(commentItem, Is.Null); }
/// <summary> /// Создает комментарий. /// </summary> /// <param name="comment">Комментарий.</param> /// <returns>Идентификаторо созданного комментария.</returns> public int Create(CommentItem comment) { if (string.IsNullOrEmpty(comment.Text)) { throw new Exception("Поле 'Text' не должно быть пустым."); } return(_commentRepository.Create(comment)); }
/// <summary> /// Gets the entry item for the current comment. /// </summary> /// <param name="commentItem">The comment item.</param> /// <returns></returns> public virtual EntryItem GetBlogEntryByComment(CommentItem commentItem) { if (commentItem == null) { return(null); } return(commentItem.InnerItem.FindAncestorByAnyTemplate(Settings.EntryTemplateIds)); }
/// <summary> /// Update item /// </summary> /// <param name="item">Item to update</param> /// <param name="action">Action</param> /// <returns>True on success</returns> public bool Update(CommentItem item, string action) { if (!Security.IsAuthorizedTo(Rights.ModerateComments)) { throw new UnauthorizedAccessException(); } foreach (var p in Post.Posts.ToArray()) { foreach (var c in p.Comments.Where(c => c.Id == item.Id).ToArray()) { if (action == "approve") { c.IsApproved = true; c.IsSpam = false; p.DateModified = DateTime.Now; p.Save(); return(true); } if (action == "unapprove") { c.IsApproved = false; c.IsSpam = true; p.DateModified = DateTime.Now; p.Save(); return(true); } //c.Content = item.Content; c.Author = item.Author; c.Email = item.Email; //c.Website = string.IsNullOrEmpty(item.Website) ? null : new Uri(item.Website); if (item.IsPending) { c.IsApproved = false; c.IsSpam = false; } if (item.IsApproved) { c.IsApproved = true; c.IsSpam = false; } if (item.IsSpam) { c.IsApproved = false; c.IsSpam = true; } // need to mark post as "dirty" p.DateModified = DateTime.Now; p.Save(); return(true); } } return(false); }
private void deleteCommentCallback(CommentItem obj) { if (obj.Comment.cid == 0L) { return; } this._virtPanel.RemoveItem((IVirtualizable)obj); GroupsService.Current.DeleteComment(this._gid, this._tid, obj.Comment.cid, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => this.PublishChangedEvent())); }
private void replyCallback(CommentItem obj) { TextBox textBoxNewComment = this.newCommentUC.TextBoxNewComment; string str = textBoxNewComment.Text + string.Format("[post{0}|{1}], ", (object)obj.Comment.cid, (object)obj.NameWithoutLastName); textBoxNewComment.Text = (str); ((Control)this.newCommentUC.TextBoxNewComment).Focus(); this.newCommentUC.TextBoxNewComment.Select(this.newCommentUC.TextBoxNewComment.Text.Length, 0); }
public EventModel addCommentToEvent(EventModel e, CommentItem c) { List <CommentItem> comments = e.getComments(); comments.Add(c); e.setComments(comments); saveEvent(e); return(e); }
protected void buttonSaveComment_Click(object sender, EventArgs e) { if (MessagePanel != null) { MessagePanel.Visible = false; } if (Page.IsValid) { Comment comment = new Comment { AuthorName = GetFormValue(txtCommentName), AuthorEmail = GetFormValue(txtCommentEmail), Text = GetFormValue(txtCommentText) }; comment.Fields.Add(Constants.Fields.Website, GetFormValue(txtCommentWebsite)); comment.Fields.Add(Constants.Fields.IpAddress, Context.Request.UserHostAddress); var result = ValidateCommentCore.Validate(comment, Request.Form); ID submissionResult = null; if (result.Success) { submissionResult = SubmitCommentCore.Submit(comment); if (submissionResult.IsNull) { SetErrorMessage(Translator.Text("COMMENT_SUBMIT_ERROR")); } else { SetSuccessMessage(Translator.Text("COMMENT_SUBMIT_SUCCESS")); ResetCommentFields(); } } else { var text = string.Join(", ", result.Errors); SetErrorMessage(text); } //check if added comment is available. if so, send it along with the event //won't happen unless publishing and indexing is really fast, but worth a try var newCommentReference = CommentManager.GetEntryComments(Sitecore.Context.Item, int.MaxValue).SingleOrDefault(item => item.Uri.ItemID == submissionResult); CommentItem newComment = null; if (newCommentReference != null) { newComment = Database.GetItem(newCommentReference.Uri); } Sitecore.Events.Event.RaiseEvent(Constants.Events.UI.COMMENT_ADDED, new object[] { newComment }); //display javascript to scroll right to the comments list CommentScroll.Visible = true; } }
/// <summary> /// Gets the entry item for the current comment. /// </summary> /// <param name="commentItem">The comment item.</param> /// <returns></returns> public EntryItem GetBlogEntryByComment(CommentItem commentItem) { Item[] blogEntry = commentItem.InnerItem.Axes.GetAncestors().Where(item => item.TemplateIsOrBasedOn(Settings.EntryTemplateID)).ToArray(); if (blogEntry.Length > 0) { return(new EntryItem(blogEntry.FirstOrDefault())); } return(null); }
public ActionResult Submit(string title, string text) { CommentItem comment = Engine.Definitions.CreateInstance <CommentItem>(CurrentItem); comment.Title = Server.HtmlEncode(title); comment.Text = Server.HtmlEncode(text); Engine.Persister.Save(comment); return(RedirectToAction("index")); }
public HttpResponseMessage DeleteAll([FromBody] CommentItem item) { var action = Request.GetRouteData().Values["id"].ToString(); if (action.ToLower() == "pending" || action.ToLower() == "spam") { repository.DeleteAll(action); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task Update(CommentItem comment) { using (var session = SessionManager.OpenSession()) using (var transaction = session.BeginTransaction()) { await session.UpdateAsync(comment); await transaction.CommitAsync(); } }
public IActionResult DeleteAll([FromBody] CommentItem item) { var action = ControllerContext.RouteData.Values["id"].ToString().ToLowerInvariant(); if (action.ToLower() == "pending" || action.ToLower() == "spam") { repository.DeleteAll(action); } return(Ok()); }
/// <summary> /// Get the name of the blog entry a comment was made against /// </summary> /// <param name="comment">The comment to find the blog entry title for</param> /// <returns>The title if found, otherwise an empty string</returns> public virtual string GetEntryTitleForComment(CommentItem comment) { if (comment != null) { return(ManagerFactory.EntryManagerInstance.GetBlogEntryByComment(comment).Title.Text); } else { return(string.Empty); } }
/// <summary> /// Get the URL of the blog entry a comment was made against /// </summary> /// <param name="comment">The comment to find the blog entry URL for</param> /// <returns>The URL if found, otherwise an empty string</returns> public virtual string GetEntryUrlForComment(CommentItem comment) { if (comment != null) { return(LinkManager.GetItemUrl(ManagerFactory.EntryManagerInstance.GetBlogEntryByComment(comment).InnerItem)); } else { return(string.Empty); } }
public override Item newItem(XmlNode node, XmlEditor document) { Item item = null; if (node.NodeType == XmlNodeType.Element) { item = new ElementItem(document); } else if (node.NodeType == XmlNodeType.Attribute ) { item = new AttrItem(document); } else if (node.NodeType == XmlNodeType.Text) { item = new TextItem(document); } else if (node.NodeType == XmlNodeType.ProcessingInstruction ) { item = new ProcessingInstructionItem(document); } else if (node.NodeType == XmlNodeType.XmlDeclaration ) { item = new DeclarationItem(document); } else if (node.NodeType == XmlNodeType.Comment) { item = new CommentItem(document); } else if (node.NodeType == XmlNodeType.CDATA) { item = new CDATAItem(document); } else if (node.NodeType == XmlNodeType.DocumentType) { item = new DocumentTypeItem(document); } else if (node.NodeType == XmlNodeType.EntityReference) { item = new EntityReferenceItem(document); } //item.m_document = document; return item; }
void _postsList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { var comments = sender as ObservableCollection<MainViewModel.post_with_username_wrapper>; if (comments != null) { //start from new startindex for (int i = e.NewStartingIndex; i < comments.Count; i++) { MainViewModel.post_with_username_wrapper c = comments[i]; var newcom = new CommentItem(); newcom.UserImage.Background = new ImageBrush() { Stretch = Stretch.UniformToFill, ImageSource = Constants.ByteArrayToImageConverter.Convert(c.userImage) }; c.PropertyChanged += (s, a) => { newcom.UserImage.Background = new ImageBrush() { Stretch = Stretch.UniformToFill, ImageSource = Constants.ByteArrayToImageConverter.Convert(c.userImage) }; }; newcom.CommentText.Text = c.post.text; newcom.NameText.Text = c.post.name + " " + c.post.lastname; newcom.DateText.Text = " " + c.post.created_at.Date.ToString(); _mainpanel.Children.Add(newcom); } } }
/// <summary> /// получаем комменты /// </summary> private void ListCommentsCallback() { var requestString = string.Format("https://api.vk.com/method/wall.getComments?access_token={0}&owner_id={1}&post_id={2}&sort=desc", Client.Instance.Access_token.token, _uid, _postId); requestString = _uidlist.Aggregate(requestString, (current, item) => current + ("," + item)); var web = (HttpWebRequest)WebRequest.Create(requestString); web.Method = "POST"; web.ContentType = "application/x-www-form-urlencoded"; web.BeginGetResponse(delegate(IAsyncResult e) { var request = (HttpWebRequest)e.AsyncState; var response = (HttpWebResponse)request.EndGetResponse(e); var responseReader = new StreamReader(response.GetResponseStream()); try { var responseString = responseReader.ReadToEnd(); var o = JObject.Parse(responseString); try { var responseArray = (JArray)o["response"]; for (var i = 1; i < responseArray.Count; i++) { var commentItem = new CommentItem { Cid = (int)responseArray[i]["cid"], Uid = (int)responseArray[i]["uid"], Date = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds( Convert.ToDouble((int)responseArray[i]["date"])), Text = (string)responseArray[i]["text"] }; //if ((int)responseArray[i]["reply_to_uid"] > 0) { commentItem.ReplyToUid = (int)responseArray[i]["reply_to_uid"]; } //if ((int)responseArray[i]["reply_to_cid"] > 0) { commentItem.ReplyToCid = (int)responseArray[i]["reply_to_cid"]; } FeedItem.Comments.Add(commentItem); _uidlist.Add((int)responseArray[i]["uid"]); } } catch { switch ((int)o["error"]["error_code"]) { case 212: { Dispatcher.BeginInvoke(() => { CommentBox.Visibility = Visibility.Collapsed; MessageBox.Show("Вы не можете читать и оставлять комментарии"); }); break; } } } Dispatcher.BeginInvoke(ListProfileCallback); } catch (Exception exception) { Dispatcher.BeginInvoke(() => MessageBox.Show(exception.Message)); } }, web); if (progressBar1.IsIndeterminate == false) { progressBar1.IsIndeterminate = true; } }
// 创建一个CommentItem // parameter: // strValue 值 public CommentItem CreateCommentItem(string strValue) { CommentItem item = new CommentItem(this); item.SetValue(strValue); return item; }