private void ProcessPost(string vkTopicId, responseCommentsComment comment, VkGroup group) { var savedComment = this.topicRepository.GetTopicComment(group.Id, comment.id); if (savedComment != null) { this.log.DebugFormat("Topic comment with VkId={0} is already in database", comment.id); return; } if (this.processingStrategy.IsLimitedProcessingEnabled(group.Id, DataFeedType.TopicComment) && comment.date.FromUnixTimestamp().AddMonths(this.processingStrategy.GetMonthLimit()) < DateTime.UtcNow) { this.log.DebugFormat("Fetched topic comment with VkId={0} is created more than {1} months ago. Skipping.", comment.id, this.processingStrategy.GetMonthLimit()); return; } savedComment = new TopicComment { VkId = comment.id, VkTopicId = vkTopicId, VkGroupId = group.Id, PostedDate = comment.date.FromUnixTimestamp(), CreatorId = long.Parse(comment.from_id) }; this.topicRepository.SaveComment(savedComment); this.log.DebugFormat("Topic comment with VkId={0} is not found in database. Saved with Id={1}", savedComment.VkId, savedComment.Id); }
private void Bind() { if (!Id.Equals(Guid.Empty)) { Page.Title = "编辑话题评论"; TopicComment bll = new TopicComment(); DataSet ds = bll.GetModelOW(Id); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; txtContent.Value = dt.Rows[0]["ContentText"].ToString(); UserId.Value = dt.Rows[0]["UserId"].ToString(); tsId.Value = dt.Rows[0]["TopicSubjectId"].ToString(); hId.Value = Id.ToString(); isTop.Value = Request["isTop"]; if (Convert.ToBoolean(dt.Rows[0]["IsDisable"])) { rdFalse.Checked = false; rdTrue.Checked = true; } else { rdFalse.Checked = true; rdTrue.Checked = false; } } } else { tsId.Value = Request["tsId"]; } }
/// <summary> /// 获取指定话题评论内容 /// </summary> /// <param name="groupId">群ID</param> /// <param name="topicId">话题ID</param> /// <param name="page">页码(默认1)</param> /// <param name="count">每页数据量(默认15,最大30)</param> /// <returns></returns> public TopicComment GetTopicComment(int groupId, int topicId, int page = 1, int count = 15) { var request = CreateRequest(RestSharp.Method.GET, "group/topic_comment"); request.AddParameter("access_token", context.Token.access_token, RestSharp.ParameterType.QueryString); request.AddParameter("group_id", groupId, RestSharp.ParameterType.QueryString); request.AddParameter("topic_id", topicId, RestSharp.ParameterType.QueryString); request.AddParameter("page", page, RestSharp.ParameterType.QueryString); request.AddParameter("count", count, RestSharp.ParameterType.QueryString); var response = restClient.Execute(request); if (CheckError(response)) { throw GenerateError(response); } TopicComment result = null; try { result = Deserialize <TopicComment>(response.Content); } catch (System.InvalidOperationException) { result = new TopicComment() { status = "success", info = new TopicComment.Info() }; return(result); } return(result); }
public async Task <IActionResult> Post([FromBody] TopicComment model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var appUser = await this._appUserRepo.GetAppUser(model.AppUserId.GetValueOrDefault()); if (appUser == null) { return(NotFound()); } var topicCommentsForMember = await this._topicRepo.GetTopicCommentsForMember(model.AppUserId.GetValueOrDefault()); if (topicCommentsForMember.Count() > 0) { return(BadRequest("投稿は1日1回のみです")); } model.PhotoId = appUser.MainPhotoId; model.DisplayName = appUser.DisplayName; _topicRepo.Add(model); if (await _topicRepo.SaveAll() > 0) { return(CreatedAtRoute("GetTopicComment", new { id = model.Id }, model)); } return(BadRequest("投稿に失敗しました")); }
public void SaveComment(TopicComment comment) { try { this.topicRepository.SaveComment(comment); this.cachingStrategy.StoreItem(comment); } catch (DbException exc) { ExceptionHandler.HandleSaveException(exc, comment, "topiccomment"); } }
public void UpdateComment(TopicComment topicComment) { if (topicComment == null) { return; } using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { dataGateway.Connection.Execute(@"update topiccomment set vkid = @VkId, creatorid = @CreatorId, posteddate = @PostedDate, year = @Year, month = @Month, week = @Week, day = @Day, hour = @Hour, minute = @Minute, second = @Second, vkgroupid = @VkGroupId, vktopicid = @VkTopicId where id = @Id", topicComment); } }
public void SaveComment(TopicComment comment) { if (!comment.IsTransient()) { return; } using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { comment.Id = dataGateway.Connection.Query <int>(@"insert into topiccomment(vkid, creatorid, posteddate, year, month, week, day, hour, minute, second, vkgroupid, vktopicid) values (@VkId, @CreatorId, @PostedDate, @Year, @Month, @Week, @Day, @Hour, @Minute, @Second, @VkGroupId, @VkTopicId) RETURNING id", comment).First(); } }
public JsonResult AddComment(int topicId, string text) { int userId = db.Users.FirstOrDefault(x => x.Email == User.Identity.Name).Id; var comment = new TopicComment() { UserId = userId, TopicId = topicId, Comment = text, CommentDate = DateTime.Now }; db.TopicComments.Add(comment); db.SaveChanges(); return(Json(new { Comment = comment.Comment, Date = comment.CommentDate.ToString("dd/MM/yyyy"), Author = comment.User.FirstName + " " + comment.User.LastName })); }
public async Task AddNotificationNewPostOnTopicComment(int appUserId, TopicComment topicComment) { var fromUser = await _context.AppUsers.FirstOrDefaultAsync(au => au.Id == appUserId); await AddNotificationIfNotExist(new Notification() { AppUserId = (int)topicComment.AppUserId, NotificationType = NotificationEnum.NewPostOnTopicComment, RecordType = "TopicComment", RecordId = topicComment.Id, FromUserName = fromUser.DisplayName, TargetRecordTitle = topicComment.Comment, // Message = "あなたの一言『" + topicComment.Comment + "』に新しいコメントがあります" }); }
private void Bind() { int totalRecords = 0; if (!string.IsNullOrEmpty(tsId.Value)) { //查询条件 GetSearchItem(); TopicComment bll = new TopicComment(); rpData.DataSource = bll.GetListOW(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); } myDataAppend.Append("<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"); }
public async Task AddNotificationRepliedForTopicComment(TopicComment topicComment) { var previousOwnerReply = await _context.TopicReplies.Where(tr => tr.TopicCommentId == topicComment.Id && tr.AppUserId == topicComment.AppUserId) .OrderByDescending(tr => tr.DateCreated).FirstOrDefaultAsync(); List <TopicReply> notifyingReplies = null; if (previousOwnerReply == null) { notifyingReplies = await _context.TopicReplies.Where(tr => tr.TopicCommentId == topicComment.Id ).GroupBy(tr => tr.AppUserId) .Select(g => g.First()) .ToListAsync(); } else { notifyingReplies = await _context.TopicReplies.Where(tr => tr.TopicCommentId == topicComment.Id && tr.DateCreated > previousOwnerReply.DateCreated ).GroupBy(tr => tr.AppUserId) .Select(g => g.First()) .ToListAsync(); } var commentOwner = await _context.AppUsers.FirstOrDefaultAsync(au => au.Id == topicComment.AppUserId); foreach (var reply in notifyingReplies) { if (reply.AppUserId != null) { await AddNotificationIfNotExist(new Notification() { AppUserId = (int)reply.AppUserId, NotificationType = NotificationEnum.RepliedOnTopicComment, RecordType = "TopicComment", RecordId = reply.TopicCommentId, Photo = topicComment.Photo, FromUserName = commentOwner.DisplayName, TargetRecordTitle = topicComment.Comment, // Message = "あなたのコメントに返信がありました(一言トピック:" + topicComment.Comment + ")" }); } } }
public IResult CreateTopicComment(AddTopicCommentDto addTopicCommentDto) { var errorResult = BusinessRules.Run(CheckAuthenticatedUserExist(), IsTopicExist(addTopicCommentDto.TopicId)); if (errorResult != null) { return(errorResult); } var user = _authService.GetAuthenticatedUser().Result.Data; var topic = _uow.Topics.Get(x => x.Id == addTopicCommentDto.TopicId); var topicComment = new TopicComment() { UserId = user.Id, Comment = addTopicCommentDto.Comment }; topic.TopicComments.Add(topicComment); _uow.Topics.Update(topic); _uow.Commit(); return(new SuccessResult(Message.TopicCommentCreated)); }
public IndividualTopicCommentResponse UpdateTopicComment(TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(GenericPut <IndividualTopicCommentResponse>(string.Format("topics/{0}/comments/{1}.json", topicComment.TopicId, topicComment.Id), body)); }
public IndividualTopicCommentResponse CreateTopicComment(long topicId, TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(GenericPost <IndividualTopicCommentResponse>(string.Format("topics/{0}/comments.json", topicId), body)); }
public ActionResult Post(TopicCommentVM newCom) { if (newCom.CommentToAdd.Comment.AuthorName != null && newCom.CommentToAdd.Comment.CommentText != null) { TopicComment toAdd = new TopicComment(); toAdd.Comment = newCom.CommentToAdd.Comment; blogData.SetCommentOnTopic(toAdd, newCom.topic.TopicId); return RedirectToAction("Post"); } else { return RedirectToAction("Post"); } }
public void UpdateComment(TopicComment comment) { this.topicRepository.UpdateComment(comment); this.cachingStrategy.StoreItem(comment); }
public Task AddNotificationRepliedForTopicComment(TopicComment topicComment) { throw new System.NotImplementedException(); }
public Task AddNotificationNewPostOnTopicComment(int appUserId, TopicComment topicComment) { throw new System.NotImplementedException(); }
public async Task <IndividualTopicCommentResponse> UpdateTopicCommentAsync(TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(await GenericPutAsync <IndividualTopicCommentResponse>($"topics/{topicComment.TopicId}/comments/{topicComment.Id}.json", body)); }
public IndividualTopicCommentResponse UpdateTopicComment(TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(GenericPut <IndividualTopicCommentResponse>($"topics/{topicComment.TopicId}/comments/{topicComment.Id}.json", body)); }
public async Task <IndividualTopicCommentResponse> CreateTopicCommentAsync(long topicId, TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(await GenericPostAsync <IndividualTopicCommentResponse>(string.Format("topics/{0}/comments.json", topicId), body)); }
public async Task <IndividualTopicCommentResponse> UpdateTopicCommentAsync(TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(await GenericPutAsync <IndividualTopicCommentResponse>(string.Format("topics/{0}/comments/{1}.json", topicComment.TopicId, topicComment.Id), body)); }
public IndividualTopicCommentResponse CreateTopicComment(long topicId, TopicComment topicComment) { var body = new { topic_comment = topicComment }; return(GenericPost <IndividualTopicCommentResponse>($"topics/{topicId}/comments.json", body)); }