internal VssRevision(VssItem item, RevisionRecord revision, CommentRecord comment) { this.item = item; this.action = CreateAction(revision, item); this.revision = revision; this.comment = comment; }
private Task PrepareCommentVotingNotifications(CommentRecord comment, string currentUserId) { var commentCreatorConnection = NotificationHub.Connections.SingleOrDefault(o => o.UserId == comment.Creator); //todo // var commentCreatorNotificationNum = 1;// _context.Notification.Count(o => o.ToUserId == comment.Creator && o.IsSeen == false) + 1; //(await _session.QueryIndex<AutoroutePartIndex>(o => o.ContentItemId != context.ContentItem.ContentItemId && o.Path == path).CountAsync()) /*var notification = new Notification * { * Content = comment.Content, * CreatedUtc = DateTime.Now, * GroupId = comment.GroupId, * IsSeen = false, * FromUserId = currentUserId, * NotificationType = NotificationType.AddReplyOnComment, * Title = string.Format(" liked your comment "), * CorrelationId = comment.Id.ToString(), * Event = "Comment", * ToUserId = comment.Creator * }; * * // _context.Notification.Add(notification); * * await _notificationRepository.InsertAsync(notification);*/ if (commentCreatorConnection != null) { //todo // await _realTimeNotifier.HubContext().Clients.Client(commentCreatorConnection.ConnectionID).SendAsync("RefreshNotificationNum", commentCreatorNotificationNum); } return(Task.CompletedTask); }
public static void LoadFromDatabase() { // load and loop to fill data... CommentRecord comment = new CommentRecord(); comment.Id = 2; Records.Add(comment); }
public void CheckIfFieldIsCommentOrDate(CommentRecord currentRecord, string field) { if (char.IsLetter(field[0])) { currentRecord.Comment = currentRecord.Comment.Append(field); } else { currentRecord.DateTime = currentRecord.DateTime.Append(field); } }
protected VssRevision CreateRevision(RevisionRecord revision) { CommentRecord comment = null; if (revision.CommentLength > 0 && revision.CommentOffset > 0) { comment = new CommentRecord(); ItemFile.ReadRecord(comment, revision.CommentOffset); } else if (revision.Action == VssPhysicalLib.Action.Label && revision.LabelCommentLength > 0 && revision.LabelCommentOffset > 0) { comment = new CommentRecord(); ItemFile.ReadRecord(comment, revision.LabelCommentOffset); } return(CreateRevision(revision, comment)); }
public void WhenWePassListOfRecordsThenReturnTheCommentsWithCountInDictionaryAfterRemovingStopWords() { var wordCount = new WordFrequencyGenerator(); var record1 = new CommentRecord(new StringBuilder("1/1/2020 12:30"), new StringBuilder("Code should be decoupled")); var record2 = new CommentRecord(new StringBuilder("20/2/2020 13:10"), new StringBuilder("No additional Comments")); var record3 = new CommentRecord(new StringBuilder("10/3/2020 19:09"), new StringBuilder("No additional Comments")); var commentRecord = new List <CommentRecord> { record1, record2, record3 }; var frequencyList1 = new Dictionary <string, int> { ["code"] = 1, ["should"] = 1, ["be"] = 1, ["decoupled"] = 1, ["no"] = 2, ["additional"] = 2, ["comments"] = 2 }; var frequencyList2 = new Dictionary <string, int> { ["code"] = 1, ["decoupled"] = 1, ["additional"] = 2, ["comments"] = 2 }; Assert.True(wordCount.GenerateFrequencyList(commentRecord).SequenceEqual(frequencyList2)); Assert.False(wordCount.GenerateFrequencyList(commentRecord).SequenceEqual(frequencyList1)); }
public ActionResult CreateCommandRecord(FormCollection data) { if (string.IsNullOrEmpty(User.Identity.Name)) { return RedirectToAction("Details", "Spots", new { id = data["Spot.spot_ID"] }); } CommentRecord commentRecord = new CommentRecord() { spot_ID = int.Parse(data["Spot.spot_ID"]), comment_context = data["Command"], comment_grade = data["Grade"], user_ID = int.Parse(User.Identity.Name), comment_date = System.DateTime.Now }; //SpotRepository.CreateCommand(commentRecord) //暫先用linq新增 db.CommentRecord.Add(commentRecord); db.SaveChanges(); return RedirectToAction("Details", "Spots", new { id = data["Spot.spot_ID"] }); }
protected override VssRevision CreateRevision(RevisionRecord revision, CommentRecord comment) { return(new VssFileRevision(this, revision, comment)); }
public void UpdateUserCommendRecord(CommentRecord commentRecord) { db.Database.ExecuteSqlCommand( @"UPDATE [dbo].[CommentRecord] SET [comment_date] = @comment_date, [comment_grade] =@comment_grade, [comment_context] = @comment_context WHERE [commentrecord_ID] = @commentrecord_ID ", new SqlParameter("@user_name", commentRecord.commentrecord_ID), new SqlParameter("@user_tel", commentRecord.comment_date), new SqlParameter("@comment_grade", commentRecord.comment_grade), new SqlParameter("@comment_context", commentRecord.comment_context) ); db.SaveChanges(); }
internal VssFileRevision(VssItem item, RevisionRecord revision, CommentRecord comment) : base(item, revision, comment) { }
public async Task <IActionResult> PostComment(CommentRecordViewModel comment) { // string userId = SignInManager // .AuthenticationManager // .AuthenticationResponseGrant.Identity.GetUserId(); byte[] file = await GetCommentAttachedFile(comment); // var currentUserId = _userManager.GetUserId(User); //comment.Id = Guid.NewGuid().ToString(); comment.CreatedByCurrentUser = false; // comment.Creator = currentUserId; comment.IsNew = true; comment.CreatedByCurrentUser = true; #region Get the current comment root Id CommentRecord parent = null; if (comment.Parent != null) { // parent = _context.Comment.SingleOrDefault(o => o.Id == comment.Parent); parent = await _commentRepository.FindByIdAsync(comment.Parent.GetValueOrDefault()); if (parent != null) { // if (string.IsNullOrEmpty(parent.Parent)) if (parent.Parent != null) { comment.Root = parent.Id; } else { comment.Root = parent.Root; } } } #endregion if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var commentModel = new CommentRecord() { Content = comment.Content ?? "", CreatedUtc = DateTime.Now, CreatedByAdmin = false, Creator = comment.Creator, FileMimeType = comment.FileMimeType, FileURL = comment.FileURL, // Id = comment.Id, ContentItemId = comment.ContentItemId, Parent = comment.Parent, Root = comment.Root, UpvoteCount = 0, UserHasUpvoted = false, UserVoted = "", CreatedByCurrentUser = false, IsNew = false, UpdatedUtc = DateTime.Now, Pings = comment.Pings != null?string.Join(",", comment.Pings) : null, File = file, GroupId = parent != null ? parent.GroupId : comment.GroupId, CommentGroupType = parent != null ? parent.CommentGroupType : comment.CommentGroupType }; comment.GroupId = commentModel.GroupId; comment.CommentGroupType = commentModel.CommentGroupType; // _context.Comment.Add(commentModel); await _commentRepository.InsertAsync(commentModel); comment.Id = commentModel.Id; comment.CreatedUtc = commentModel.CreatedUtc; // CreateTransaction(comment, currentUserId, CommentTransactionType.Add); #region prepare all Notifications types /* * //maybe could use field indexes to get group members * var groupMembersQuery = _session.QueryIndex<ContentPickerFieldIndex>(x =>x.SelectedContentItemId == comment.ContentItemId); * var groupMemberIdResults = (await groupMembersQuery.ListAsync()).Select(x=> x.ContentItemId); */ //push notifications await _pushNotificationService.PushCommentToGroupMembers(comment.ContentItemId, comment.ToCommentDetailsView()); //await _pushNotificationService.PushNotifications(connectedUserNotificationNumList, _commentsRetrievalService.GetCommentView(newComment.Id)?.ToCommentDetailsView()); //await PrepareCommentNotifications(comment, comment.Creator); #endregion // await _context.SaveChangesAsync(); return(Json(comment)); }
protected abstract VssRevision CreateRevision(RevisionRecord revision, CommentRecord comment);