public ActionResult Send(CommentSendModel model) { if (model.Page == 0) { model.Page = 1; } int recordCount = 0; Users.ClearCfgCommentCount(CurrentUser.ID); model.CurSkinCss = CurrentCssUrl; model.CurUser = CurrentUser; model.CurUserConfig = CurrentUserConfig; IList <Comment> comments = Comments.GetSendCommentsByPager(model.CurUser.ID, model.Key, model.Page, 20, ref recordCount); model.Comments = comments; model.PageSize = 20; model.RecordCount = recordCount; return(View(model)); }
public async Task <IActionResult> SendCommend([FromForm] CommentSendModel model, [FromQuery] uint cid) { if (ModelState.IsValid) { //TODO:判断发送的评论是否有script,iframe,object标签 model.ContentId = cid; var res = await _commentRepository.SendCommentAsync(_userManager.GetUserId(User), model.ContentId, model.SendText); if (res != null) { ModelState.AddModelError(string.Empty, res); return(await Get(model.ContentId)); } return(await Get(model.ContentId)); } return(await GetDetailAsync(model.ContentId, locpage : 0, sendModel : new CommentSendModel() { SendText = model.SendText, ContentId = model.ContentId })); }
private async Task <ContentDetailViewModel> MakeDetailViewModelAsync(uint contentId, int locpage, int prePageCount = 6, bool useJs = false, CommentSendModel sendModel = null) { var content = await _contentRepository.GetContentAsync(contentId); await _contentRepository.LoadFilesAsync(content); if (content == null) { return(null); } bool like = false; var user = await _userManager.GetUserAsync(User); if (User != null) { like = await _contentRepository.IsLikeContentAsync(user, contentId); } var comms = await _contentRepository.GetContentCommentsAsync(content.Id, prePageCount, locpage *prePageCount); foreach (var item in comms.Datas) { item.UserName = await _dbContext.Users.Where(u => u.Id == item.EaUserId).Select(u => u.UserName).FirstOrDefaultAsync(); } await _contentRepository.LoadFilesAsync(content); var retModel = new ContentDetailViewModel(content) { Sender = user, Comments = comms.Datas, IsLike = like, SendModel = sendModel ?? new CommentSendModel() { ContentId = contentId }, LocPage = locpage, UseJs = useJs, TotalCount = comms.Total }; return(retModel); }
private async Task <IActionResult> GetDetailAsync(uint contentId, int locpage, int prePageCount = 6, bool useJs = false, CommentSendModel sendModel = null) { var res = await MakeDetailViewModelAsync(contentId, locpage, prePageCount, useJs, sendModel); if (res == null) { return(View(ViewHelper.MessageView, new MessageModel("错误内容id", "Home", "Index", "主页"))); } return(View("_ContentDetail", res)); }