private async Task <CommentOutput> CreateComment(Comment item) { string liked = "", delete = ""; if (item.Likes.FirstOrDefault(x => x.Owner == User.Identity.Name) != null) { liked += " checked "; } if (!User.Identity.IsAuthenticated) { liked += " disabled "; } if (item.Owner == userManager.GetUserName(User) || (User.Identity.IsAuthenticated && await userManager.IsInRoleAsync(await userManager.GetUserAsync(User), "Admin"))) { delete = "<button href=\"#\" title=\"\" value=\"" + item.CommentId + "\" class=\"btn-link cmnt-delete\"><span class=\"glyphicon glyphicon-remove\"></span></button>"; } CommentOutput output = new CommentOutput() { CommentId = item.CommentId, Count = item.Likes.Count, CreationDate = item.CreationTime.ToString("HH:mm:ss dd.MM.yyyy"), Liked = liked, Delete = delete, Owner = item.Owner, Content = item.Content }; return(output); }
public override async Task GetCommentsOfTask(Int32Value request, IServerStreamWriter <CommentOutput> responseStream, ServerCallContext context) { var result = await _dataAccess.GetCommentsOfTasktDataAccessAsync(request.Value); if (result is null) { await responseStream.WriteAsync(new CommentOutput()); return; } foreach (var model in result) { var task = new CommentOutput { CommentId = model.CommentId, SenderId = model.SenderId, SenderFirstName = model.SenderFirstName, SenderLastName = model.SenderLastName, Message = model.Message }; await responseStream.WriteAsync(task); } }
/// <summary> /// 查看所有商品评论 /// </summary> /// <param name="goodid"></param> /// <param name="pid"></param> /// <returns></returns> public List <CommentOutput> GetGoodComment(string goodid, int page, int limte, string pid) { var list = new List <CommentOutput>(); var data = EF.Comments.Where(a => a.Number == goodid && a.ParentId == pid && a.IsDelect == true).OrderBy(a => a.CreateTime).ToList(); if (data.Count == 0) { return(null); } foreach (var item in data) { var mod = new CommentOutput() { CommentId = item.CommentId, Content = item.Content, CreateTime = item.CreateTime, Number = item.Number, UserId = item.UserId, UserName = EF.UserInfos.FirstOrDefault(a => a.UserID == item.UserId).UserName, ParentId = item.ParentId, SupportCount = item.SupportCount, OpposeCount = item.OpposeCount, ChlidCom = GetGoodComment(goodid, page, limte, item.CommentId) }; list.Add(mod); } return(list); }
public Task AddComment(int id, CommentOutput comment) { return(Clients.Group(id.ToString()).SendAsync("addcomment", comment)); }
private static string GetCommentQuoteBody(CommentOutput output) { return(output.HasQuote ? Resource.DeletedComment : output.Body); }
private static string GetCommentBody(CommentOutput output) { return(output.IsDeleted ? Resource.DeletedComment : output.Body); }