public async Task <int> Update(CommentsInfo entity) { if (entity != null) { _context.CommentsInfo.Update(entity); await _context.SaveChangesAsync(); return(1); } return(0); }
private void ProcessReceivedData(bool loadFromEndSaved, bool refresh, CommentsInfo commentsInfo) { Execute.ExecuteOnUIThread((Action)(() => { if (!this._isLoaded && !refresh && this._knownCommentsCount < commentsInfo.TotalCommentsCount || (loadFromEndSaved != this._loadFromEnd || refresh && this._knownCommentsCount < commentsInfo.TotalCommentsCount)) { this._knownCommentsCount = commentsInfo.TotalCommentsCount; this._isLoading = false; this.LoadData(true, (Action <bool>)null); } else { List <IVirtualizable> itemsToInsert = new List <IVirtualizable>(); foreach (Comment comment in commentsInfo.comments) { Comment c = comment; CommentItem commentItem = this.CreateCommentItem(commentsInfo.profiles.FirstOrDefault <User>((Func <User, bool>)(u => u.uid == c.from_id)), c, commentsInfo.groups.FirstOrDefault <VKClient.Common.Backend.DataObjects.Group>((Func <VKClient.Common.Backend.DataObjects.Group, bool>)(g => g.id == -c.from_id))); itemsToInsert.Add((IVirtualizable)commentItem); } if (refresh) { this._alreadyLoadedCommentsCount = 0; this._virtPanel.ClearItems(); } this.EnsurePollIsAdded(commentsInfo); bool flag = (refresh || !this._isLoaded) && this._loadFromEnd; if (this._loadFromEnd) { if (flag) { this._virtPanel.OnlyPartialLoad = true; } this._virtPanel.InsertRemoveItems(this.GetIndexOfFirstLoadedComment(), itemsToInsert, true, (IVirtualizable)null); } else { this._virtPanel.AddItems((IEnumerable <IVirtualizable>)itemsToInsert); } this._alreadyLoadedCommentsCount = this._alreadyLoadedCommentsCount + itemsToInsert.Count; if (flag) { this._virtPanel.ScrollToBottom(true); } this._isLoading = false; this._isLoaded = true; } })); }
public async Task <int> Add(CommentsInfo entity) { if (entity != null) { if (entity.Likes == true) { entity.Likes = true; } else { entity.Dislike = true; } entity.CreatedAt = DateTime.Now; await _context.CommentsInfo.AddAsync(entity); await _context.SaveChangesAsync(); return(entity.Id); } return(0); }
public void Save(CommentingUserAccountModel model) { var currentUser = CurrentRequestData.CurrentUser; CommentsInfo commentsInfo; if (currentUser.Get <CommentsInfo>() != null) { commentsInfo = currentUser.Get <CommentsInfo>(); } else { commentsInfo = new CommentsInfo { User = currentUser }; _userProfileDataService.Add(commentsInfo); } _session.Transact(session => { commentsInfo.Username = model.Username; session.SaveOrUpdate(commentsInfo); }); }
private void EnsurePollIsAdded(CommentsInfo commentsInfo) { if (this._loadFromEnd) { return; } List <IVirtualizable> virtualizableItems = this._virtPanel.VirtualizableItems; Func <IVirtualizable, bool> func = (Func <IVirtualizable, bool>)(vi => vi is PollItem); if (virtualizableItems.FirstOrDefault <IVirtualizable>(func) != null || commentsInfo.poll == null || commentsInfo.poll.poll_id == 0L) { return; } PollItem pollItem = new PollItem(480.0, new Thickness(0.0), commentsInfo.poll, this._tid); MyVirtualizingPanel2 virtPanel = this._virtPanel; int index = 0; List <IVirtualizable> itemsToInsert = new List <IVirtualizable>(); itemsToInsert.Add((IVirtualizable)pollItem); int num = 0; virtPanel.InsertRemoveItems(index, itemsToInsert, num != 0, null); }
public JsonResult CreateComments(int newsId, int parentId, string comment) { int userId = -1; if (Session["UserId"] != null) { userId = int.Parse(Session["UserID"].ToString()); } string userName = ""; if (Session["UserName"] != null) { userName = Session["UserName"].ToString(); } BLLComments bllCom = new BLLComments(); CommentsInfo commentsInfo = new CommentsInfo { CommentDate = DateTime.Now, Comment = comment, ParentCommentID = parentId, Ip = Request.UserHostAddress, PostID = newsId, UserName = userName, UserId = userId }; //添加评论 bllCom.Insert(commentsInfo); //查询评论 var CommentList = bllCom.GetDataByPostID(newsId); return(Json(new { data = CommentList }, JsonRequestBehavior.DenyGet)); }
//===================================================================== /// <summary> /// This is used to write the comments to the appropriate assembly XML comments file /// </summary> private void WriteComments() { CommentsInfo lastComments = null; string fullPath; // Assembly names are compared case insensitively var writers = new Dictionary <string, XmlWriter>(StringComparer.OrdinalIgnoreCase); try { foreach (var comments in commentsList.GetConsumingEnumerable()) { lastComments = comments; if (String.IsNullOrWhiteSpace(comments.AssemblyName)) { continue; } if (!writers.TryGetValue(comments.AssemblyName, out XmlWriter writer)) { fullPath = Path.Combine(outputFolder, comments.AssemblyName + ".xml"); XmlWriterSettings settings = new XmlWriterSettings { Indent = true }; try { writer = XmlWriter.Create(fullPath, settings); } catch (IOException ioEx) { this.WriteMessage(comments.MemberName, MessageLevel.Error, "An access error occurred " + "while attempting to create the IntelliSense output file '{0}'. The error message " + "is: {1}", fullPath, ioEx.Message); } writers.Add(comments.AssemblyName, writer); writer.WriteStartDocument(); writer.WriteStartElement("doc"); writer.WriteStartElement("assembly"); writer.WriteElementString("name", comments.AssemblyName); writer.WriteEndElement(); writer.WriteStartElement("members"); } writer.WriteStartElement("member"); writer.WriteAttributeString("name", comments.MemberName); if (comments.Summary != null) { writer.WriteNode(comments.Summary, true); } foreach (XPathNavigator nav in comments.Params) { writer.WriteNode(nav, true); } foreach (XPathNavigator nav in comments.TypeParams) { writer.WriteNode(nav, true); } if (comments.Returns != null) { writer.WriteNode(comments.Returns, true); } if (comments.Value != null) { writer.WriteNode(comments.Value, true); } foreach (XPathNavigator nav in comments.Exceptions) { writer.WriteNode(nav, true); } foreach (XPathNavigator nav in comments.CodeContracts) { writer.WriteNode(nav, true); } writer.WriteFullEndElement(); if (comments.EnumElements != null) { foreach (var kv in comments.EnumElements) { writer.WriteStartElement("member"); writer.WriteAttributeString("name", kv.Key); writer.WriteNode(kv.Value, true); writer.WriteFullEndElement(); } } } } catch (IOException ioEx) { this.WriteMessage(lastComments.MemberName, MessageLevel.Error, "An access error occurred while " + "attempting to write IntelliSense data. The error message is: {0}", ioEx.Message); } catch (XmlException xmlEx) { this.WriteMessage(lastComments.MemberName, MessageLevel.Error, "IntelliSense data was not valid " + "XML. The error message is: {0}", xmlEx.Message); } finally { // Write out closing tags and close all open XML writers when done foreach (XmlWriter w in writers.Values) { w.WriteEndDocument(); w.Close(); } } }
public async Task <ActionResult> CreateComments(CommentsInfo data) { var model = await _commentsInfoService.Add(data); return(Ok(model)); }
public PartialViewResult Show(CommentsInfo info) { return(PartialView(info)); }
public RedirectToRouteResult Delete_POST(CommentsInfo info) { _userProfileDataService.Delete(info); return(RedirectToAction("Edit", "User", new { id = info.User.Id })); }
public PartialViewResult Delete(CommentsInfo info) { return(PartialView(info)); }