public JsonResult SubComment([FromBody] SubCommentParam msg) { ReplyModel reply = new ReplyModel(); try { Comment.SubComment(_commentRepository, msg); bool result = ServiceProvider.GetService <IUnitOfWork>().Commit(); if (result) { reply.Status = "002"; reply.Msg = "评论成功"; } else { reply.Msg = "评论失败"; } } catch (Exception ex) { reply.Msg = $"提交评论出现异常,请重试{ex.Message}"; } return(Json(reply)); }
protected void btnDoQuestion_Click(object sender, EventArgs e) { if (CurrentUser == null || !CurrentUser.IsAuthenticated) { Response.Redirect("/Login.aspx?returnurl=" + Request.RawUrl); return; } string ErrorMessage = String.Empty; if (String.IsNullOrEmpty(txtTile.Text.Trim())) { ErrorMessage += "标题不能为空;"; } if (String.IsNullOrEmpty(txtContent.Text.Trim())) { ErrorMessage += "内容不能为空"; } if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(this, ErrorMessage); return; } ReplyBll rbll = new ReplyBll(); ReplyModel rmodel = new ReplyModel(); rmodel.TopicId = int.Parse(hidTopicId.Value); rmodel.Content = txtContent.Text.Trim(); rmodel.Title = txtTile.Text.Trim(); rmodel.UserId = CurrentUser.UserId; rbll.Add(rmodel); txtContent.Text = ""; txtTile.Text = ""; ShowReplyInfo(); }
public ActionResult Info() { ReplyServiceClient client = new ReplyServiceClient(); AdvancedResult <PageEntity <GenReply> > replys = client.LoadMyBBReplyList(CurrentToken, 0, 9); IList <ReplyModel> models = new List <ReplyModel>(); if (replys.Error == AppError.ERROR_SUCCESS) { ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption; bindOptions.BindReplyCount = 0; bindOptions.ProductBindType = bindOptions.ProductBindType | ProductBindType.ReplyCount; bindOptions.ReplayBindType = ReplyBindType.Author | ReplyBindType.Product; models = ReplyModel.BindList(replys.Data.Items, bindOptions); } foreach (ReplyModel r in models) { if (r.Author != null && r.Author.HeadPic != null) { r.Author.HeadPic.DisplaySeting(50, 50); } } return(View("~/Views/User/Info.cshtml", models)); }
public async Task <JsonResult> Reply(ReplyModel replyModel) { var currUser = _sessionManager.CurrUser; try { //查询目标用户信息 if (!await _dbContext.User.AnyAsync(s => s.Id == replyModel.TargetUserId)) { return(Json(new ApiResult(-1, "回复的用户不存在"))); } RemarkReply remarkReply = new RemarkReply(); remarkReply.Content = replyModel.ReplyContent; remarkReply.TargetUserId = replyModel.TargetUserId; remarkReply.RemarkId = replyModel.RemarkId; remarkReply.UserId = currUser.Id; remarkReply.CreateTime = DateTime.Now; await _dbContext.RemarkReply.AddAsync(remarkReply); if (await _dbContext.SaveChangesAsync() > 0) { _logger.LogWarning($"用户{currUser.Name}—回复评论—成功"); //查询所在文章 Article article = await _dbContext.Article.SingleOrDefaultAsync(s => s.Id == replyModel.ArticleId); if (article == null) { _logger.LogWarning($"回复评论时—添加用户消息—查询当前文章—NULL。"); } else { if (!article.AllowReply) { return(Json(new ApiResult(-1, "文章禁止回复"))); } //添加用户消息 UserMessage userMessage = new UserMessage(replyModel.TargetUserId, Configuration["UserMessageTemp:RemarkReply"].Replace("{UserName}", currUser.Name).Replace("{ArticleId}", replyModel.ArticleId.ToString()).Replace("{ArticleTitle}", article.Title).Replace("{ReplyId}", remarkReply.Id.ToString()), (int)UserMessageType.Remark); await _dbContext.UserMessage.AddAsync(userMessage); if (await _dbContext.SaveChangesAsync() <= 0) { _logger.LogWarning($"回复评论—添加用户消息—失败"); } else { _logger.LogInformation($"回复评论—添加用户消息—成功"); } } return(Json(ApiResultAccessor.Successfully)); } else { _logger.LogWarning($"用户{currUser.Name}—回复评论—失败"); return(Json(ApiResultAccessor.Unsuccessful)); } } catch (Exception ex) { _logger.LogError(ex, $"用户{currUser.Name},回复评论出错。"); return(Json(ApiResultAccessor.Exception)); } }
public ReplyValidator(ReplyModel model) { _model = model; }
public static Reply ToEntity(this ReplyModel model, Reply destination) { return(model.MapTo(destination)); }
public ReplyModel Update(int id, ReplyModel ReplyModel) { throw new NotImplementedException(); }
/// <summary> /// 新增评论 /// </summary> /// <param name="contentId"></param> /// <param name="replyInfo"></param> /// <param name="fileIds">评论上传附件集合</param> /// <param name="replyId"></param> /// <returns></returns> public object CerateReply(int contentId, string replyInfo, string fileIds, int?replyId) { ContentReply reply = new ContentReply(); reply.Info = replyInfo; reply.ContentId = contentId; reply.CreationTime = DateTime.Now; if (replyId != null) { reply.ParentId = (long)replyId; } else { reply.ParentId = null; } if (AbpSession.UserId != null) { reply.DeleteUid = (long)AbpSession.UserId;//因有约束条件FK_EM_CONTENT_REPLY_DELETE_UID 则删除人默认等于创建人 reply.ReolyUId = (long)AbpSession.UserId; //reply.ReplyUser = _userRepository.Get(reply.ReolyUId); } var rId = _contentReplyRepository.InsertAndGetId(reply); //保存评论附件上传文件 //上传附件ID集合 var fileIdList = fileIds.Split(','); int fileNumber = 0; if (fileIdList.Count() > 0) { //保存上传附件和评论ID foreach (var item in fileIdList) { if (item != "" && item != "删除") { var fileId = item.ToInt32(); if (fileId != 0) { ContentReplyFile rfiles = new ContentReplyFile { ContentReplyId = rId, FileId = fileId }; _contentReplyFileRepository.Insert(rfiles); fileNumber++; } } } } var result = _contentReplyRepository.Get(rId); ReplyModel rm = new ReplyModel { Info = result.Info, ContentId = result.ContentId, Id = result.Id, CreationTime = result.CreationTime, ReplyUserName = _userRepository.Get(result.ReolyUId).Name, //返回上传附件数量,刚刚上传,查询不出来 //IsFileNumber=_contentReplyFileRepository.GetAll().Count(x=>x.ContentReplyId== result.Id) IsFileNumber = fileNumber }; if (result.ParentId != null) { rm.ParentName = _contentReplyRepository.FirstOrDefault((long)result.ParentId).ReplyUser.Name; } var content = _contentRepository.Get(contentId); var defineType = _contentTypeRepository.Get(content.DefineTypeId); var defineId = Convert.ToInt32(defineType.DefineId); //获取内容权限 var defineConfig = _defineConfigRepository.GetAll().SingleOrDefault(a => a.DefineId == defineId); if (defineConfig != null) { rm.IsReolyFloor = Convert.ToBoolean(defineConfig.IsReolyFloor); } if (defineConfig != null) { rm.IsLike = Convert.ToBoolean(defineConfig.IsLike); } if (defineConfig != null) { rm.IsReolyFile = Convert.ToBoolean(defineConfig.IsReolyFile); } if (defineConfig != null) { rm.IsReolyFloorFile = Convert.ToBoolean(defineConfig.IsReolyFloorFile); } return(rm); }
/// <summary> /// 农机手我的应答列表 /// </summary> /// <add></add> /// <param PublishStateId>100507 待农机手评价</param> /// <param PublishStateId>100508 待大农户评价</param> /// <returns></returns> public List <ReplyModel> GetReplyList(int pageindex, int pagesize, int isclosed, long userid, out long TotalNums) { using (var dbContext = new DuPont_TestContext()) { //应答列表中的地址是大农户发布需求时的地址 List <ReplyModel> list = new List <ReplyModel>(); //进行中 if (isclosed == 0) { TotalNums = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 && (fpd.PublishStateId == 100502 || fpd.PublishStateId == 100507 || fpd.PublishStateId == 100508 ) select drr.Id).Count(); if (TotalNums == 0) { return(null); } list = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code join user in dbContext.T_USER on fpd.CreateUserId equals user.Id where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 && (fpd.PublishStateId == 100502 || fpd.PublishStateId == 100507 || fpd.PublishStateId == 100508 ) orderby drr.CreateTime descending select new { drr.Id, fpd.DemandTypeId, fpd.CreateTime, fpd.Province, fpd.City, fpd.Region, fpd.Township, fpd.Village, fpd.DetailedAddress, fpd.PhoneNumber, fpd.Brief, fpd.PublishStateId, fpd.AcresId, user.UserName, fpd.CreateUserId, DemandTypeName = dic.DisplayName }).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList() .Select( model => { var item = new ReplyModel { Id = model.Id, Requirement = model.DemandTypeName, PublishedDate = Utility.TimeHelper.GetMilliSeconds(model.CreateTime), Address = GetAreaName(model.Province) + GetAreaName(model.City) + GetAreaName(model.Region) + GetAreaName(model.Township) + GetAreaName(model.Village), DetailAddress = model.DetailedAddress ?? "", PhoneNumber = model.PhoneNumber, Remark = model.Brief ?? "", Status = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()), Acreage = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()), PublisherUserName = model.UserName, RoleId = (int)RoleType.Farmer, RoleName = RoleType.Farmer.GetDescription(), PublisherUserId = model.CreateUserId }; item.RequireTypeName = item.Requirement; return(item); }).ToList(); } else if (isclosed != 0)//已关闭 { TotalNums = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 && ( fpd.PublishStateId == 100503 || fpd.PublishStateId == 100504 || fpd.PublishStateId == 100505 || fpd.PublishStateId == 100506 ) select drr.Id).Count(); if (TotalNums == 0) { return(null); } list = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code join user in dbContext.T_USER on fpd.CreateUserId equals user.Id where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 && ( fpd.PublishStateId == 100503 || fpd.PublishStateId == 100504 || fpd.PublishStateId == 100505 || fpd.PublishStateId == 100506 ) orderby drr.CreateTime descending select new { drr.Id, fpd.DemandTypeId, fpd.CreateTime, fpd.Province, fpd.City, fpd.Region, fpd.Township, fpd.Village, fpd.DetailedAddress, fpd.PhoneNumber, fpd.Brief, fpd.PublishStateId, fpd.AcresId, user.UserName, fpd.CreateUserId, DemandTypeName = dic.DisplayName }).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList() .Select( model => { var item = new ReplyModel { Id = model.Id, Requirement = model.DemandTypeName, PublishedDate = Utility.TimeHelper.GetMilliSeconds(model.CreateTime), Address = GetAreaName(model.Province) + GetAreaName(model.City) + GetAreaName(model.Region) + GetAreaName(model.Township) + GetAreaName(model.Village), DetailAddress = model.DetailedAddress ?? "", PhoneNumber = model.PhoneNumber, Remark = model.Brief ?? "", Status = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()), Acreage = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()), PublisherUserName = model.UserName, RoleId = (int)RoleType.Farmer, RoleName = RoleType.Farmer.GetDescription(), PublisherUserId = model.CreateUserId }; item.RequireTypeName = item.Requirement; return(item); }).ToList(); } else { TotalNums = 0; list = null; } return(list); } }
/// <summary> /// 回复表的修改 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int ReplyUpdate(ReplyModel mm) { return(dal.ReplyUpdate(mm)); }
/// <summary> ///回复表的删除 /// </summary> /// <param name="mm"></param> /// <returns></returns> public int ReplyDelete(ReplyModel mm) { return(dal.ReplyDelete(mm)); }
/// <summary> /// 回复表的添加 /// </summary> /// <returns></returns> public int ReplyADD(ReplyModel mm) { return(dal.ReplyADD(mm)); }
public async Task Update(object obj) { ReplyModel replyModel = obj as ReplyModel; await dbSave.Save(db); }
public async Task <JsonResult> Reply(ReplyModel replyModel) { var currUser = _sessionManager.CurrUser; var logInfo = $"【{currUser.Name}】回复留言"; try { //信息验证 if (replyModel.ReplyContent.IsNullOrWhiteSpace()) { return(Json(new ApiResult(-1, "回复内容不能为空"))); } if (replyModel.ReplyContent.Length > 500) { return(Json(new ApiResult(-1, "内容必须少于500个字符"))); } if (replyModel.RemarkId == 0) { return(Json(new ApiResult(-1, "回复失败"))); } //查询目标用户信息 if (!await _dbContext.User.AnyAsync(s => s.Id == replyModel.TargetUserId)) { return(Json(new ApiResult(-1, "回复的用户不存在"))); } CommentReply commnetReply = new CommentReply(); commnetReply.Content = replyModel.ReplyContent; commnetReply.TargetUserId = replyModel.TargetUserId; commnetReply.CommentId = replyModel.RemarkId; commnetReply.UserId = currUser.Id; commnetReply.CreateTime = DateTime.Now; await _dbContext.CommentReply.AddAsync(commnetReply); if (await _dbContext.SaveChangesAsync() > 0) { _logger.LogInformation($"{logInfo}-成功"); //添加用户消息 UserMessage userMessage = new UserMessage(replyModel.TargetUserId, Configuration["UserMessageTemp:CommentReply"].Replace("{UserName}", currUser.Name).Replace("{Content}", replyModel.ReplyContent), (int)UserMessageType.Comment); await _dbContext.UserMessage.AddAsync(userMessage); if (await _dbContext.SaveChangesAsync() <= 0) { _logger.LogWarning($"回复留言—添加用户消息—失败"); } //查询刚才添加的回复信息返回给客户端 var reply = await _dbContext.CommentReply.Where(s => s.Id == commnetReply.Id).Include(s => s.TargetUser).Include(s => s.User).SingleOrDefaultAsync(); return(Json(new ApiResultWithData <CommentReply>(reply, 1, "操作成功"))); } else { _logger.LogWarning($"{logInfo}-失败"); return(Json(ApiResultAccessor.Unsuccessful)); } } catch (Exception ex) { _logger.LogError(ex, $"{logInfo}-出错"); return(Json(ApiResultAccessor.Exception)); } }
public CommentModel addreply(ReplyModel reply, int commentid) { throw new NotImplementedException(); }
public ContentResult SendReply(ReplyModel m) { var ret = m.Send(CurrentDatabase); return(Content(ret)); }
public IActionResult Create(ReplyModel model) { return(Ok(_db.Create(model))); }
public IActionResult Update(int id, ReplyModel model) { return(Ok(_db.Update(id, model))); }
public ReplyModel Create(ReplyModel ReplyModel) { _dbReference.ReplyModel.Add(ReplyModel); _dbReference.SaveChanges(); return(ReplyModel); }
public void Reply(ReplyModel model) { SendMessage(model.From, model.User, model.Subject, model.TextBody); }
public DisplayReply PostReply(ReplyModel reply) { return(PostReply(reply.To, reply.Message, reply.MessageID, reply.richMessage, reply.attachmentID)); }
public static Reply ToEntity(this ReplyModel model) { return(model.MapTo <ReplyModel, Reply>()); }