public void GetList() { int sellerid = GetInt("sellerid"); int start = GetInt("start"); int limit = GetInt("limit"); var result = CommentHelper.GetPagings(sellerid, CommentType.All, 0, start * limit, limit); var data = new PagResults <object>(); foreach (var item in result.Results) { var user = AccountHelper.GetUser(item.UserId); var feedbackStauts = item.Feedback != null && item.Feedback.Length > 0; var o = new { Id = item.Id, Title = item.Title, Content = item.Content, Feedback = item.Feedback, FeedbackStatus = feedbackStauts ? "已回复" : "未回复", CreateTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Type = EnumHelper.CommentTypeToName(item.Type), UserId = item.UserId, UserName = user.UserName, NickName = user.NickName }; data.Results.Add(o); } data.TotalCount = result.TotalCount; JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
/// <summary> /// 图片评论列表 /// </summary> /// <returns></returns> public void ImgCommentList(HttpContext context) { int pid = GetInt("pid"); int index = GetInt("start"); int size = GetInt("limit"); if (pid == 0) { ReturnErrorMsg("请传入正确的pid"); return; } SourceMaterial sm = SourceMaterialHelper.GetItem(pid); var cms = CommentHelper.GetPagings(sm.SellerId, CommentType.Img, pid, index * size, size, "order by CreateTime desc"); var data = new CommentsForApis(); data.Commentnum = cms.TotalCount; JsonTransfer jt = new JsonTransfer(); if (cms.Results.Count < 1) { jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); return; } var users = AccountHelper.GetUserList(cms.Results.Select(c => c.UserId).ToList()); foreach (var cm in cms.Results) { var user = users.FirstOrDefault(u => u.Id == cm.UserId); if (user == null) { throw new ArgumentNullException(string.Format("userId:{0}", cm.UserId)); } var result = new ComentsForApi { Avatar = Utility.GetSizePicUrl(user.Avatar, 100, 100, context), UserName = user.UserName, Sex = (int)user.Sex, Dateline = cm.CreateTime.GetUnixTime(), Message = cm.Content }; data.Comments.Add(result); } jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
private void Couponcommentlist(HttpContext context) { int cid = GetInt("couponid"); int index = GetInt("start"); int size = GetInt("limit"); var coupon = CouponHelper.GetItem(cid); var cms = CommentHelper.GetPagings(coupon.SellerId, CommentType.Coupons, cid, index * size, size); var data = new CommentsForApis(); data.Commentnum = cms.TotalCount; if (cms.TotalCount == 0) { JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); } else { var users = AccountHelper.GetUserList(cms.Results.Select(c => c.UserId).ToList()); foreach (var cm in cms.Results) { var user = users.FirstOrDefault(u => u.Id == cm.UserId); if (user == null) { throw new ArgumentNullException(string.Format("userId:{0}", cm.UserId)); } var result = new ComentsForApi { Avatar = Utility.GetSizePicUrl(user.Avatar, 100, 100, context), UserName = user.UserName, Sex = (int)user.Sex, Dateline = cm.CreateTime.GetUnixTime(), Message = cm.Content }; data.Comments.Add(result); } JsonTransfer jt = new JsonTransfer(); jt.AddSuccessParam(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); } }