// // GET: /Comment/ public ActionResult CommentList(Guid id, Guid qId) { var context = new StackOverflowContext(); var m = new CommentListCollectionModel() { Comments = new ListStack <CommentListModel>(), ParentReference = id, QuestionReference = qId }; IList <CommentListModel> models = new ListStack <CommentListModel>(); var comments = context.Comments.Include(x => x.Owner); foreach (Comment com in comments) { if (com.ReferenceToQuestionOrAnswer == id) { var c = new CommentListModel { CreationDate = com.CreationDate, Description = com.Description, OwnerIf = com.Owner.Id, ReferenceToQuestionOrAnswer = com.ReferenceToQuestionOrAnswer, ReferenceToQuestion = com.QuestionReference, OwnerName = com.Owner.Name }; m.Comments.Add(c); } } return(PartialView(m)); }
public ActionResult Comments(string postId, bool answer = false) { var comments = (from item in db.Comments where item.PostId == postId orderby item.Date select item).ToList(); CommentListModel commentModels = new CommentListModel { Comments = new List <CommentModel>(), Seed = "" }; foreach (var comment in comments) { string author = (from item in db.Users where item.Id == comment.AuthorId select item.UserName).ToList().First(); commentModels.Comments.Add(new CommentModel { AuthorName = author, Text = comment.Text, Date = comment.Date, Id = comment.Id, PostId = comment.PostId, ParentId = comment.ParentId == null ? "" : comment.ParentId, Answer = answer }); } return(PartialView(commentModels)); }
public async Task <IActionResult> Get([FromRoute] int articleId) { var article = await _articleRepository.GetAsync(articleId); if (article == null) { return(NotFound()); } var comments = await _commentRepository.Query().ToListAsync(); var result = new CommentListModel { Comments = comments.Select(c => new CommentModel { Id = c.Id, Email = c.Email, Title = c.Title, Content = c.Content, Date = c.Date, Published = c.Published }) }; return(Ok(result)); }
public ActionResult ShowArticle(int id) { Article article = repoArticle.Get(id); if (article != null) { CommentListModel commentList = new CommentListModel() { Comments = repoComments.GetComments(id).ToArray().Select(x => new PageComment() { CommentId = x.CommentId, Level = x.Level, Parent = x.Parent, Text = x.Text, UserId = x.UserId, UserName = x.UserName }) }; ViewData["Comments"] = commentList; return(View(article)); } return(NotFound()); }
public NewsItemModel() { AddNewComment = new AddNewsCommentModel(); Comments = new CommentListModel(); PictureModel = new PictureModel(); PreviewPictureModel = new PictureModel(); }
public BlogPostModel() { Tags = new List <BlogPostTagModel>(); AddNewComment = new AddBlogCommentModel(); Comments = new CommentListModel(); PictureModel = new PictureModel(); PreviewPictureModel = new PictureModel(); }
/// <summary> /// Gets the comment model. /// </summary> /// <param name="id">The optional content id</param> /// <returns>The model</returns> public async Task <CommentListModel> Get(Guid?id = null) { var model = new CommentListModel { ContentId = id }; var postComments = await _api.Posts.GetAllCommentsAsync(id, onlyApproved : false, pageSize : 0); var pageComments = await _api.Pages.GetAllCommentsAsync(id, onlyApproved : false, pageSize : 0); foreach (var postComment in postComments) { var post = await _api.Posts.GetByIdAsync <PostInfo>(postComment.ContentId); model.Comments.Add(new CommentListModel.CommentItem { Id = postComment.Id, ArticleTitle = post?.Title, ArticleUrl = $"manager/post/edit/{ post?.Id }", Author = postComment.Author, AuthorImage = Utils.GenerateGravatarUrl(postComment.Email, 25), Email = postComment.Email, Body = postComment.Body, IsApproved = postComment.IsApproved, Created = postComment.Created.ToString("yyyy-MM-dd"), CreatedDate = postComment.Created }); } foreach (var pageComment in pageComments) { var page = await _api.Pages.GetByIdAsync <PageInfo>(pageComment.ContentId); model.Comments.Add(new CommentListModel.CommentItem { Id = pageComment.Id, ArticleTitle = page?.Title, ArticleUrl = $"manager/page/edit/{ page?.Id }", Author = pageComment.Author, AuthorImage = Utils.GenerateGravatarUrl(pageComment.Email, 25), Email = pageComment.Email, Body = pageComment.Body, IsApproved = pageComment.IsApproved, Created = pageComment.Created.ToString("yyyy-MM-dd"), CreatedDate = pageComment.Created }); } model.Comments = model.Comments .OrderByDescending(c => c.CreatedDate) .ToList(); return(model); }
public ActionResult CommentUpdate(GridCommand command, CommentListModel model) { var comment = postService.GetCommentById(model.Id); if (comment != null) { comment.FullName = model.FullName; comment.Commentary = model.Comment; comment.Approved = model.Approved; postService.SaveComment(comment); } return(CommentList(command, model.PostId)); }
public async Task <IActionResult> Get([FromRoute] int?articleId) { if (articleId == null) { return(BadRequest(ApiResponse.BadRequest("Argument id is null"))); } var model = await _commentRepository.Query().Where(w => w.ArticleId == articleId).ToArrayAsync(); var result = new CommentListModel { Comments = model.Select(c => c.AsDto()) }; return(Ok(ApiResponse.Ok(result))); }
protected void Page_Load(object sender, EventArgs e) { string Ssid = Request.Params["SSID"]; string comment = Request.Params["comment"]; string time = DateTime.Now.ToString("yyMMddHHmm"); var result = new CommentListModel(); int s; if (int.TryParse(Ssid, out s)) { try { string querySql = "select `posSSID`,`negSSID`,`content`,`time` from" + "`comment_table` where `negSSID` = " + Ssid + ";"; using (MySqlConnection conn = new MySqlConnection(DatabaseManager.connStr)) { lock (conn) { conn.Open(); MySqlCommand cmd = new MySqlCommand(querySql, conn); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var commentObj = new SingleCommentObj(); commentObj.posSSID = reader[0].ToString(); commentObj.negSSID = reader[1].ToString(); commentObj.comment = reader[2].ToString(); commentObj.time = reader[3].ToString(); result.comments.Add(commentObj); } reader.Close(); } } result.status = true; } catch (Exception ex) { result.errorMsg = ex.Message; } } else { result.errorMsg = "参数错误。已记录您的这次操作"; } Response.Write(JsonConvert.SerializeObject(result)); }
/// <summary> /// 商品咨询 /// </summary> /// <param name="goodsId"></param> /// <param name="page"></param> /// <returns></returns> public virtual ActionResult Comment(long goodsId, int page) { var model = new CommentListModel { PageIndex = page }; var query = new QueryInfo(); query.SetPageIndex(model.PageIndex).SetPageSize(model.PageSize).Query <CommentEntity>().Where(it => it.Product.Goods.Id == goodsId) .OrderByDescending(it => it.Id).Select(it => new object[] { it.Account.Name, it.Detail, it.InsertTime, it.Type }); model.Comments = this.GetEntities <CommentEntity>(query); if (model.Comments == null || model.Comments.Count == 0) { return(Content("")); } return(View("~/Views/Home/_Comment.cshtml", model)); }
public async Task <IActionResult> Detail(int id) { var currentUser = await GetCurrentUserAsync(); Sharing sharing = await _sharingService.FindByIdAsync(id); if (sharing != null) { int? ownerId = sharing.UserId; User user = new User(); user = await _userManager.FindByIdAsync(ownerId.ToString()); SharingListModel model = _mapper.Map <SharingListModel>(sharing); model.UserName = user.UserName; List <Comment> comments = await _commentService.GetAllBySharingIdAsync(id); List <CommentListModel> commentModels = new List <CommentListModel>(); foreach (var item in comments) { if (item.UserId != null) { string userId = item.UserId.ToString(); var commentUser = await _userManager.FindByIdAsync(userId); bool result = false; if (currentUser != null) { result = await _commentService.isLiked(item.Id, currentUser.Id); } CommentListModel commentModel = _mapper.Map <CommentListModel>(item); commentModel.CommentOwner = commentUser.UserName; commentModel.isLiked = result; commentModels.Add(commentModel); } } ViewBag.Comments = commentModels; ViewBag.User = currentUser != null ? currentUser.UserName:""; return(View(model)); } return(BadRequest("")); }
public async Task <CommentListModel> GetListModelAsync(CommentQuery query) { CommentListModel listModel = new CommentListModel(); IQueryable <Comment> queryable = GetIncludes(p => p.AuthorUser, p => p.Article); //Article Yapan User ve Taglar Gelsin if (!string.IsNullOrWhiteSpace(query.Slug)) { var isSlug = await _articleServices.Get(p => p.Slug == query.Slug); if (isSlug != null) { queryable = queryable.Where(p => p.ArticleId == isSlug.Id); } } else { return(null); } //if (query.UserId > 0) //{ // var isUser = await _userServices.Get(p => p.Id == query.UserId); // if (isUser != null) // { // queryable = queryable.Where(p => p.AuthorUserId == isUser.Id); // } //} var commentList = queryable.OrderByDescending(p => p.UpdatedAt).Skip(query.Offset * query.Limit).Take(query.Limit).ToList(); await Task.Run(() => listModel.Comments = _mapper.Map <List <Comment>, List <CommentDto> >(commentList)); listModel.TotalCount = queryable.Count(); return(listModel); }
public ActionResult CommentModelPageData(int pageIndex, int pageSize, CommentListModel commentsModel) { var model = new EngineeringFileService().Get(e => e.Id == commentsModel.ModelId); if (model == null) { throw new ArgumentNullException(nameof(model)); } if (!new PermissionService().CanUserVisitProject(CurrentCustomer, model.Engineering.ProjectId)) { return(NoAuthorityJson()); } var lamda = PrepareCommentListLamda(commentsModel, model); PagedList <Comment> comments = GetVersionComments(pageIndex, pageSize, lamda, model, commentsModel.SelectedVersionId, commentsModel.SelectedProfessionId); var commentModels = PrepareCommentModelPageData(comments, model); var roleDes = CurrentCustomer.GetCurrentRoleDes(commentsModel.SelectedProfessionId, model.Engineering); return(Json(new { result = true, listHtml = this.RenderPartialViewToString("_Comment", commentModels), total = comments.TotalCount, roleDes = roleDes, statusDescription = model.FileVersions.FirstOrDefault(e => e.Id == commentsModel.SelectedVersionId)?.Status.GetDescription() }, JsonRequestBehavior.AllowGet)); }
public JsonResult Comment(FormCollection form) { if (!settingService.GetSetting("post.comment.enabled").BoolValue) { return(Json(new { errorMessage = "Yorum sistemi devredışı." })); } if (!string.IsNullOrEmpty(form["postId"]) && !string.IsNullOrEmpty(form["name"]) && !string.IsNullOrEmpty(form["email"]) && !string.IsNullOrEmpty(form["message"])) { var comment = new Comment { PostId = form["postId"].ToInt(), ParentId = form["parentId"].ToInt(), FullName = form["name"], EmailAddress = form["email"], Content = form["message"], IsAccept = false, CreateDate = DateTime.Now }; postService.InsertComment(comment); var model = new CommentListModel { Id = comment.Id, ParentId = comment.ParentId, FullName = comment.FullName, Content = comment.Content, CreateDate = comment.CreateDate.ToRelativeFormat() }; return(Json(model)); } return(Json(new { errorMessage = "Bir hata oluştu." })); }
protected Expression <Func <Comment, bool> > PrepareCommentListLamda(CommentListModel model, EngineeringFile modelFile) { var lastesModelVersion = modelFile.FileVersions.OrderByDescending(e => e.UpLoadeTime).FirstOrDefault(); if (lastesModelVersion == null) { throw new ArgumentException(nameof(lastesModelVersion)); } var lamda = CommentService.ExpressionTrue; lamda = lamda.And(e => e.EngineeringFileId == model.ModelId); if (model.SelectedProfessionId != 0) { lamda = lamda.And(e => e.ProfessionId == model.SelectedProfessionId); } if (!string.IsNullOrWhiteSpace(model.SelectedState)) { var states = WorkFlow.GetStatusListByDescription(model.SelectedState); lamda = lamda.And(e => states.Contains(e.Status)); } if (model.SelectedCommentType != CommentType.All) { if (model.SelectedCommentType == CommentType.Integrality) { var types = DictionaryService.IntegralityCommentTypeDictionary.Where(e => e.IsDeleted == false).Select(e => e.Id).ToArray(); lamda = lamda.And(e => types.Contains(e.CommentTypeId)); } else { var types = DictionaryService.DesignCommentTypeDictionary.Where(e => e.IsDeleted == false).Select(e => e.Id).ToArray(); lamda = lamda.And(e => types.Contains(e.CommentTypeId)); } } return(lamda); }
public async Task GetSignedUpActivityViewTestAsync() { // arrange List <PersonModel> participantList; PersonModel person1; PersonModel person2; List <CommentModel> commentList; ActivityModel activity; ActivitySignedUpViewModel retrieved; using (var contextScope = ContextFactory.Create()) { activity = await GetTestActivityAsync(); person1 = await GetTestPersonAsync( first : "First1", last : "Last1", email : "*****@*****.**", activityId : activity.ActivityId ); person2 = await GetTestPersonAsync( first : "First2", last : "Last2", email : "*****@*****.**", activityId : activity.ActivityId ); participantList = new List <PersonModel>() { person1, person2 }; commentList = new List <CommentModel>() { await GetTestCommentAsync( personId : person1.PersonId, activityId : activity.ActivityId, content : "I might be a bit late...I hope not, but it's a long drive and a long day at work." ), await GetTestCommentAsync( personId : person2.PersonId, activityId : activity.ActivityId, content : "I can't wait to try kayaking again, it's been so long." ) }; // act retrieved = await _repository.GetSignedUpActivityViewAsync(activity.ActivityId); } // assert Assert.IsTrue(participantList.Count == retrieved.ParticipantList.Count, "The participant list counts are not equal"); Assert.IsTrue(commentList.Count == retrieved.CommentList.Count, "The comment list counts are not equal"); foreach (var person in participantList) { var listPerson = new PersonListModel() { PersonName = person.PersonFirstName + " " + person.PersonLastName }; Assert.IsTrue(retrieved.ParticipantList.Exists(x => x.PersonName == listPerson.PersonName), "The person's name was not found in the list"); } foreach (var comment in commentList) { var person = participantList.First <PersonModel>(x => x.PersonId == comment.CommentPersonId); var listComment = new CommentListModel() { CommentContent = comment.CommentContent, CommentDetail = person.PersonFirstName + " " + person.PersonLastName + " on " + comment.CommentDateTime.ToString("yyyy-mm-dd") + " at " + comment.CommentDateTime.ToString("HH:mm") }; Assert.IsTrue(retrieved.CommentList.Exists(x => x.CommentContent == listComment.CommentContent && x.CommentDetail == listComment.CommentDetail), "The comment was not found in the list"); } }
public ActionResult More(Guid postId, CommentSortBy? sort, string children, int depth) { if (!sort.HasValue) sort = CommentSortBy.Best; // TODO: get suggested sort for this link, and if none, from the sub var commentTree = _commentDao.GetCommentTree(postId); var commentTreeSorter = _commentDao.GetCommentTreeSorter(postId, sort.Value); var commentTreeContext = _commentTreeContextBuilder.Build(commentTree, commentTreeSorter, children.Split(',').Select(x => Guid.Parse(x)).ToList(), limit: 20, maxDepth: 5); commentTreeContext.Sort = sort.Value; var model = new CommentListModel(); model.SortBy = sort.Value; model.CommentNodes = _commentNodeHierarchyBuilder.Build(commentTree, commentTreeContext, _userContext.CurrentUser); return Json(new { success = true, error = (string)null, html = RenderView("_CommentNodes", model) }); }
public BlogPostModel() { Tags = new List <BlogPostTagModel>(); AddNewComment = new AddBlogCommentModel(); Comments = new CommentListModel(); }
public NewsItemModel() { AddNewComment = new AddNewsCommentModel(); Comments = new CommentListModel(); }
public ActionResult Index() { return(View(CommentListModel.Get())); }
public ActionResult List(string id) { return(View(CommentListModel.GetCommentList(new Guid(id)))); }
protected CommentListModel PrepareCommentListModel(FileVersion modelVersion) { CommentListModel result = new CommentListModel(); var modelFile = modelVersion.EngineeringFile; result.ModelId = modelFile.Id; result.ProjectName = modelFile.Engineering.Project.ProjectName; result.CommentCount = modelFile.Comments.Count(); result.EngineeringName = modelFile.Engineering.Name; result.ModelStatus = modelVersion.Status; result.StatusUpdateTime = modelVersion.UpdateStateTime.ToString("yyyy-MM-dd HH:mm:ss"); result.OrganizationType = CurrentCustomer.Organization.OrganizationType; result.AvaliableProfessions.Add(new SelectListItem() { Text = "全部", Value = "0", Selected = true }); modelVersion.ModelProfessions.ToList().ForEach(e => { result.AvaliableProfessions.Add(new SelectListItem() { Text = DictionaryService.CommentProfessionDictionary.Find(n => n.Id == e.ProfessionId).DisplayName, Value = e.ProfessionId.ToString() }); }); result.AvaliableStatus.Add(new SelectListItem() { Text = "全部", Value = "", Selected = true }); WorkFlow.GetAllCommentStatus().ForEach(e => result.AvaliableStatus.Add(new SelectListItem() { Text = e, Value = e, })); result.AvaliableCommentType = EnumHelper.EnumToSelectListItem <CommentType>(); var lastesModelVersion = modelFile.FileVersions.Where(e => e.FileType == FileType.Model).OrderByDescending(e => e.UpLoadeTime).FirstOrDefault(); if (lastesModelVersion == null) { throw new ArgumentException(nameof(lastesModelVersion)); } modelFile.FileVersions.Where(e => e.FileType == FileType.Model).OrderByDescending(e => e.UpLoadeTime).ToList().ForEach(e => { if (e.Id == modelVersion.Id) { result.SelectedVersionId = e.Id; } result.AvaliableVersions.Add(new SelectListItem() { Text = string.Format("模型版本{0}", e.VersionNo), Value = e.Id.ToString(), Selected = e.Id == modelVersion.Id, }); }); result.AvaliableVersions.Find(e => e.Value == lastesModelVersion.Id.ToString()).Text = "当前版本"; return(result); }