public CommentResponse CreateComment(CommentRequest request) { List <DocumentSharingDTO> shared = default; List <string> mylist = new List <string>(); CommentResponse retval = default; if (IsCommentAvailable(request)) { retval = _DAL.CreateComment(request); shared = _documentSharingService.GetShareForDoc(new DocumentSharingRequestGetForDoc() { DocID = _markersDAL.GetMarkerByID(new RequestGetMarkers() { DocID = request.commentDTO.MarkerID }).Markers[0].DocID }).DocumentSharingDTO; if (shared != null) { //create list type string for send to all shared.ForEach(s => mylist.Add(s.UserId)); mylist.Remove(request.commentDTO.UserId); _messanger.SendMarkerToAll(mylist, retval); } } return(retval); }
public static void AddOrUpdate(string rawVideoId, CommentResponse commentRes) { using (var db = new NicoVideoDbContext()) { var comment = db.Comments.SingleOrDefault(x => x.ThreadId == rawVideoId); if (comment == null) { comment = new NicoVideoComment() { ThreadId = rawVideoId, CommentCount = commentRes.GetCommentCount() }; db.Comments.Add(comment); } else { comment.CommentCount = commentRes.GetCommentCount(); comment.SetComments(commentRes.Chat); db.Comments.Update(comment); } db.SaveChanges(); } }
private CommentResponse generateCommentsResponse(string response) { var results = JsonConvert.DeserializeObject <dynamic>(response); var commentList = new List <Comment>(); foreach (var comment in results.data.children) { commentList.Add(new Comment() { created = comment.data.created, createdDt = ConvertFromUnixTimestamp((int)comment.data.created_utc), ups = comment.data.ups, downs = comment.data.downs, id = comment.data.id, score = comment.data.score, link_url = comment.data.link_url }); } var resp = new CommentResponse { after = results.data.after, before = results.data.before, children = commentList.ToArray() }; return(resp); }
public async Task <ActionResult <CommentResponse> > PostComments([FromBody] Comments comments) { var resp = new CommentResponse { Success = "false" }; try { var purchase = _context.PurchaseHistory.FirstOrDefault(oh => oh.UserId == comments.UserId); if (purchase == null) { resp.Success = "false"; resp.Response = "User don't have access to comment"; } else { _context.Comments.Add(comments); resp.Success = "true"; resp.Response = "Comment successfully added"; } } catch { resp.Success = "false"; resp.Response = "User don't had access to add Comment"; } return(resp); }
public static void Run() { // ExStart:1 CellsApi cellsApi = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "Sample_Test_Book.xls"; String sheetName = "Sheet2"; String cellName = "A4"; String storage = ""; String folder = ""; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Cells Cloud SDK API to get comment from worksheet CommentResponse apiResponse = cellsApi.GetWorkSheetComment(fileName, sheetName, cellName, storage, folder); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("Comment:" + apiResponse.Comment.Note); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
internal void Update(CommentResponse comment) { if (comment.Comment != null) { string filter; switch (comment.Comment.ENTITY_TYPE) { case "deal": filter = $"Deal_ID='{comment.Comment.ENTITY_ID}'"; break; case "lead": filter = $"Lead_ID='{comment.Comment.ENTITY_ID}'"; break; default: return; } string RecordID = GetFirstRecordID("Заявки", filter); if (RecordID == null) { return; } UpdatingRecord record = new UpdatingRecord(); record.fields = new Dictionary <string, object> { { "Комментарий по результату", comment.Comment.ToString() } }; UpdateRecord("Заявки", RecordID, record); } }
private async Task DeleteComment(CommentResponse commentResponse) { await _commentsService.DeleteCommentAsync(commentResponse.Comment.Id); _userDialogs.Alert(message: "Удаление произведено успешно", okText: "OK"); await RequestComments(InitComment.Comment.Id); }
private void SaveResponse() { var c = new CommentResponse(); c.DateCreated = DateTime.Now; c.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; c.CommentID = CurrentComment.ID; c.Message = tbNewResponse.Text; new CommentResponseServices().Save(c); IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession(); var a = new Activity(); a.AccountID = SecurityContextManager.Current.CurrentProfile.AccountID; a.ActivityType = (int)ActivityType.NEW_COMMENT_RESPONSE; a.DateCreated = DateTime.Now; a.URL = "/Comments/" + CurrentComment.ID.ToString(); a.PerformedBy = c.EnteredBy; a.PerformedFor = CurrentComment.EnteredForRef.ID; new ActivityServices().Save(a); string emails = ""; foreach (var r in CurrentComment.Communication.GroupBy(cust => cust.EnteredBy).Select(grp => grp.First())) { emails += r.EnteredByRef.Email + ","; } EmailHelper.SendCommentResponseNotification(c, emails); }
public CommentResponse CreateComment(CommentRequest request) { CommentResponse retval = default; try { var parameters = _paramConverter.ConvertToParameters(request.commentDTO); var dataset = _SQLDAL.ExecSPQuery("CreateComment", con, parameters); if (dataset.Tables[0].Rows.Count != 0) { retval = new CommentResponseAddOK() { comments = new List <CommentDTO>() { request.commentDTO } }; return(retval); } } catch (Exception e) { retval = new CommentResponseDontAdd(); //log } return(retval); }
public async Task <IActionResult> PutCommentResponse(int id, CommentResponse commentResponse) { if (id != commentResponse.Id) { return(BadRequest()); } _context.Entry(commentResponse).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentResponseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public CommentResponse DeleteComment(CommentRequestDelete request) { CommentResponse retval = default; try { var parameter = _paramConverter.ConvertToParameter(request, "CommentID"); var dataset = _SQLDAL.ExecSPQuery("RemoveComment", con, parameter); if (dataset.Tables[0].Rows.Count != 0) { retval = new CommentResonseRemoveOk() { comments = new List <CommentDTO>() { new CommentDTO() { CommentID = request.CommentID } } }; } } catch (Exception e) { retval = new CommentResponseDontRemove(); //log } return(retval); }
public CommentResponse GetCommentsForDocument(CommentRequestGetByDocID DocID) { CommentResponse retval = default; try { var parameter = _paramConverter.ConvertToParameter(DocID, "DocID"); var dataset = _SQLDAL.ExecSPQuery("GetCommentsForDocument", con, parameter); if (dataset != null && dataset.Tables[0].Rows.Count != 0) { retval = new CommentResponse() { comments = new List <CommentDTO>() }; var commentsList = dataset.Tables[0].AsEnumerable().Select(dataRow => new CommentDTO { CommentID = dataRow.Field <Guid>("CommentID"), MarkerID = dataRow.Field <Guid>("MarkerID"), UserId = dataRow.Field <string>("UserId"), Content = dataRow.Field <string>("Content"), CommentDate = dataRow.Field <DateTime>("CommentDate") }).ToList(); retval.comments = commentsList; } } catch (Exception e) { //log throw; } return(retval); }
public Task <CommentResponse> GetTicketComments(long id) { var comments = TicketComments(id).ToArray(); var response = new CommentResponse { Comments = comments }; return(Task.FromResult(response)); }
public async Task <IActionResult> NewComment(PostSlugViewModelWrapper model, [FromServices] ISessionBasedCaptcha captcha) { try { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new CommentResponse(false, CommentResponseCode.InvalidModel))); } if (!_blogConfig.ContentSettings.EnableComments) { Response.StatusCode = (int)HttpStatusCode.Forbidden; return(Json(new CommentResponse(false, CommentResponseCode.CommentDisabled))); } // Validate BasicCaptcha Code if (!captcha.ValidateCaptchaCode(model.NewCommentViewModel.CaptchaCode, HttpContext.Session)) { Logger.LogWarning("Wrong Captcha Code"); ModelState.AddModelError(nameof(model.NewCommentViewModel.CaptchaCode), "Wrong Captcha Code"); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new CommentResponse(false, CommentResponseCode.WrongCaptcha))); } var commentPostModel = model.NewCommentViewModel; var response = await _commentService.CreateAsync(new NewCommentRequest(commentPostModel.PostId) { Username = commentPostModel.Username, Content = commentPostModel.Content, Email = commentPostModel.Email, IpAddress = HttpContext.Connection.RemoteIpAddress.ToString() }); if (_blogConfig.NotificationSettings.SendEmailOnNewComment && null != _notificationClient) { _ = Task.Run(async() => { await _notificationClient.NotifyNewCommentAsync(response, s => Utils.MarkdownToContent(s, Utils.MarkdownConvertType.Html)); }); } var cResponse = new CommentResponse(true, _blogConfig.ContentSettings.RequireCommentReview ? CommentResponseCode.Success : CommentResponseCode.SuccessNonReview); return(Json(cResponse)); } catch (Exception e) { Logger.LogError(e, "Error NewComment"); Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new CommentResponse(false, CommentResponseCode.UnknownError))); } }
protected CommentResponse BuildCommentResponse( Comment comment, bool canUserSeeNotApprovedComments, DefaultDictionary <int, List <Comment> > replies, DefaultDictionary <int, int> commentLikesCount, HashSet <int> likedByUserCommentsIds, [CanBeNull] Dictionary <string, List <Group> > authorId2Groups, [CanBeNull] HashSet <string> authorsWithPassed, [CanBeNull] HashSet <int> userAvailableGroups, bool canViewAllGroupMembers, bool addCourseIdAndSlideId, bool addParentCommentId, bool addReplies ) { var commentInfo = new CommentResponse { Id = comment.Id, Text = comment.Text, RenderedText = CommentTextHelper.RenderCommentTextToHtml(comment.Text), Author = BuildShortUserInfo(comment.Author), PublishTime = comment.PublishTime, IsApproved = comment.IsApproved, IsLiked = likedByUserCommentsIds.Contains(comment.Id), LikesCount = commentLikesCount[comment.Id], IsPassed = authorsWithPassed?.Contains(comment.AuthorId) ?? false, Replies = new List <CommentResponse>() }; if (authorId2Groups != null && userAvailableGroups != null && authorId2Groups.ContainsKey(comment.Author.Id)) { commentInfo.AuthorGroups = authorId2Groups[comment.AuthorId] .Where(g => canViewAllGroupMembers || userAvailableGroups.Contains(g.Id)) .Select(BuildShortGroupInfo) .ToList().NullIfEmpty(); } if (addCourseIdAndSlideId) { commentInfo.CourseId = comment.CourseId; commentInfo.SlideId = comment.SlideId; } if (addParentCommentId && !comment.IsTopLevel) { commentInfo.ParentCommentId = comment.ParentCommentId; } if (!comment.IsTopLevel) { commentInfo.IsCorrectAnswer = comment.IsCorrectAnswer; return(commentInfo); } commentInfo.IsPinnedToTop = comment.IsPinnedToTop; if (addReplies) { var commentReplies = FilterVisibleComments(replies[comment.Id], canUserSeeNotApprovedComments); commentInfo.Replies = BuildCommentsListResponse(commentReplies, canUserSeeNotApprovedComments, null, commentLikesCount, likedByUserCommentsIds, authorId2Groups, authorsWithPassed, userAvailableGroups, canViewAllGroupMembers, addCourseIdAndSlideId, addParentCommentId, addReplies); } return(commentInfo); }
// コメントのキャッシュまたはオンラインからの取得と更新 public async Task <List <Chat> > GetComments() { if (CommentServerInfo == null) { return(new List <Chat>()); } CommentResponse commentRes = null; try { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await this.HohoemaApp.NiconicoContext.Video .GetCommentAsync( (int)HohoemaApp.LoginUserId, CommentServerInfo.ServerUrl, CommentServerInfo.DefaultThreadId, CommentServerInfo.ThreadKeyRequired )); }); } catch { } if (commentRes?.Chat.Count == 0) { try { if (CommentServerInfo.CommunityThreadId.HasValue) { commentRes = await ConnectionRetryUtil.TaskWithRetry(async() => { return(await this.HohoemaApp.NiconicoContext.Video .GetCommentAsync( (int)HohoemaApp.LoginUserId, CommentServerInfo.ServerUrl, CommentServerInfo.CommunityThreadId.Value, CommentServerInfo.ThreadKeyRequired )); }); } } catch { } } if (commentRes != null) { CachedCommentResponse = commentRes; CommentDb.AddOrUpdate(RawVideoId, commentRes); } return(commentRes?.Chat); }
public CommentResponse GetCommentsForDocument(CommentRequestGetByDocID request) { CommentResponse retval = default; if (request.DocID != null && request.DocID != Guid.Empty) { retval = _DAL.GetCommentsForDocument(request); } return(retval); }
public ActionResult DeleteResponse(int ID) { CommentResponse comment = context.CommentResponse.Find(ID); context.CommentResponse.Remove(comment); context.SaveChanges(); return(RedirectToAction("Comments")); }
public static CommentResponse mapFormCommentToCommentResponse(Comment comment) { CommentResponse result = new CommentResponse(); result.Id = comment.Id; result.Message = comment.Message; result.Author = comment.Author; result.ThumbsUp = comment.ThumbsUp; result.ThumbsDown = comment.ThumbsDown; return(result); }
public IActionResult postComment([FromBody] CommentDTO commentPost) { CommentResponse cmtRp = new CommentResponse(); ICollection <CommentEntity> listCommentOfProduct; if (commentPost.userID == 0 || null == userDAO.getOneById(commentPost.userID)) { return(BadRequest(new { message = "Vui lòng đăng nhập trước khi thực hiện chức năng này." })); } else { CommentEntity commentResponse = new CommentEntity(); commentResponse.userID = commentPost.userID; commentResponse.user = userDAO.getOneById(commentPost.userID); if (commentPost.productID == 0 || null == product2DAO.getProduct(commentPost.productID)) //cần thêm kiểm tra trên order của khách hàng { return(BadRequest(new { message = "Sản phẩm không tồn tại trong hệ thống!" })); } else { if (null != commentDAO.checkUserCommentProductById(commentPost.productID, commentPost.userID)) { return(BadRequest(new { message = "Bạn đã đánh giá sản phẩm này rồi. Cảm ơn bạn đã mua sản phẩm!" })); } //save to table commentResponse.createdDate = System.DateTime.Now; commentResponse.rate = commentPost.rate; Console.WriteLine("rating post = " + commentPost.rate + ", db=" + commentResponse.rate); commentResponse.productID = commentPost.productID; commentResponse.Product = product2DAO.getProduct(commentPost.productID); commentResponse.user = userDAO.getOneById(commentPost.userID); commentResponse.active = 1; commentResponse.content = commentPost.content; int commentID = commentDAO.Save(commentResponse); //kiem tra xem trong order của user có productID này không ? //TODO // if (commentID == 0) { return(BadRequest(new { message = "Hệ thống đang gặp sự cố!" })); } else { commentResponse.id = commentID; listCommentOfProduct = (ICollection <CommentEntity>)commentDAO.getAllByProductID(commentResponse.productID); cmtRp.listCommentByProduct = listCommentOfProduct; cmtRp.computeSumOfList(); cmtRp.computeTbcRate(); } } return(Ok(cmtRp)); } }
private CommentResponse GetCommentResponse(Comment comment) { try { var commentResponse = new CommentResponse(comment); commentResponse.OfficialReplied = comment.UserId == comment.Feedback.UserId; commentResponse.IsSpam = _context.Spams.Where(s => s.CommentId == comment.Id).Count() > 10; return(commentResponse); }catch (Exception) { return(null); } }
public TicketResponse Convert(Ticket ticket) { var ticketDto = new TicketResponse { Id = ticket.Id, Title = ticket.Title, Description = ticket.Description, Priority = ticket.Priority.ToString(), Status = ticket.Status.ToString(), CreatedOn = ticket.CreatedAt.ToString(), UpdatedOn = ticket.UpdatedAt.ToString(), Submitter = ticket.Submitter.UserName, Assignee = ticket.Assignee != null ? ticket.Assignee.UserName : "", AssigneeId = ticket.AssigneeId != null ? ticket.Assignee.Id : "", Project = ticket.Project.Name }; if (ticket.Audits != null) { foreach (var audit in ticket.Audits) { var auditDto = new AuditResponse { Id = audit.Id, Property = audit.Property, NewValue = audit.NewValue, OldValue = audit.OldValue, Date = audit.Date.ToString() }; ticketDto.Audits.Add(auditDto); } } if (ticket.Comments != null) { foreach (var comment in ticket.Comments) { var commentDto = new CommentResponse { Id = comment.Id, Message = comment.Message, Writer = comment.Writer.UserName }; ticketDto.Comments.Add(commentDto); } } return(ticketDto); }
public async Task <ActionResult <CommentResponse> > PostCommentResponse(CommentResponseViewModel vm) { CommentResponse response = new CommentResponse(); var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var user = _context.Users.Find(userId); response.User = user; response.Comment = _context.Comments.Find(vm.CommentId); response.ResponseDateTime = DateTime.Now; response.Content = vm.Content; _context.CommentResponses.Add(response); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCommentResponse", new { id = response.Id }, response)); }
private async Task AddComment(CommentResponse comment) { if (string.IsNullOrEmpty(_settingsService.AuthAccessToken) || string.IsNullOrEmpty(_settingsService.UserName)) { await CoreMethods.PushPageModel <LoginPageModel>(); } else { await CoreMethods.PushPageModel <AddCommentPageModel>(new AddCommentParam { ParentIsArticle = false, ParentId = comment.Comment.Id }); } }
public async Task AddCommentResponse(CommentResponse commentResponse) { commentResponse.Text = await _censorshipService.CensorText(commentResponse.Text); try { await _context.CommentResponses.AddAsync(commentResponse); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
protected void CommentsItemCommand(object o, DataListCommandEventArgs e) { if (e.CommandName == "commentresponse") { var lb = e.Item.FindControl("lbPostReponse") as LinkButton; var cr = new CommentResponse(); cr.CommentID = Convert.ToInt32(lb.Attributes["postid"]); cr.DateCreated = DateTime.Now; cr.EnteredBy = SecurityContextManager.Current.CurrentUser.ID; cr.Message = ((System.Web.UI.WebControls.TextBox)e.Item.FindControl("tbEnterResponse")).Text; new CommentResponseServices().Save(cr); _cache.Remove(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_CommentsFeed"); LoadComments(); } }
private void LoadAnswersCommentsToResponse(AnswerEntity entity, AnswerResponse response) { entity.Comments.ToList().ForEach(comment => { var newComment = new CommentResponse { Id = comment.Id, Body = comment.Body, User = new UserResponse { Id = comment.UserId } }; response.Comments.Add(newComment); }); }
private void LoadCommentsToResponse(QuestionEntity entity, QuestionResponse response) { entity.Comments.ToList().ForEach(comment => { var newComment = new CommentResponse() { Id = comment.Id, Body = comment.Body, User = new UserResponse { Id = comment.UserId } }; response.Comments.Add(newComment); }); }
public ActionResult EditResponse(int?ID) { if (ID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommentResponse model = context.CommentResponse.Find(ID); if (model == null) { return(HttpNotFound()); } return(View(model)); }
public CommentResponse MapModelToResponse(Comment comment) { if (comment == null) { return(null); } var commentResponse = new CommentResponse { Id = comment.Id, UserId = comment.UserId, CardId = comment.CardId, Content = comment.Content, DateCreated = comment.DateCreated }; return(commentResponse); }