public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; long wishId = 0; string content = String.Empty; CY.UME.Core.Business.Wishing wish; CY.UME.Core.Business.Account account; #region validate if (context.Request.Form["wishId"] == null || !long.TryParse(context.Request.Form["wishId"].ToString(), out wishId) || context.Request.Form["content"] == null) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } content = context.Request.Form["content"].ToString().Trim(); if (content.Length == 0) { context.Response.Write("{success:false,msg:'回复内容不能为空'}"); return; } wish = CY.UME.Core.Business.Wishing.Load(wishId); if (wish == null) { context.Response.Write("{success:false,msg:'该愿望不存在或已被删除'}"); return; } account = CY.UME.Core.Global.GetCurrentAccount(); if (account == null) { context.Response.Write("{success:false,msg:'用户登录超时失败'}"); return; } #endregion try { CY.UME.Core.Business.WishingComment wc = new CY.UME.Core.Business.WishingComment(); wc.AuthorId = account.Id; wc.Content = content; wc.DateCreated = DateTime.Now; wc.InstanceId = wish.Id; wc.Save(); context.Response.Write("{success:true,AuthorName:'" + account.Name + "',commentId:" + wc.Id + "}"); } catch { context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}"); } }
public int AddWishComment(long accountId, long wishId, string content) { CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(accountId); if (account == null) { return 3; } CY.UME.Core.Business.Wishing wish = CY.UME.Core.Business.Wishing.Load(wishId); if (wish == null) { return 3; } if (content.Trim().Length > 100) { return 2; } CY.UME.Core.Business.WishingComment wc = new CY.UME.Core.Business.WishingComment(); wc.AuthorId = accountId; wc.Content = content.Trim(); wc.DateCreated = DateTime.Now; wc.InstanceId = wishId; try { wc.Save(); wish.ReplyNum++; wish.Save(); return 1; } catch { return 0; } }