コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string autoId = context.Request["id"];

            if (string.IsNullOrEmpty(autoId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                apiResp.msg  = "id 为必填项,请检查";
                bllReview.ContextResponse(context, apiResp);
                return;
            }
            ReviewInfo model = bllReview.GetReviewByAutoId(int.Parse(autoId));

            if (model == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                apiResp.msg  = "评论已经删除";
                bllReview.ContextResponse(context, apiResp);
                return;
            }
            if (bllReview.Delete(new ReviewInfo(), string.Format(" WebsiteOwner='{0}' AND AutoID={1}", bllReview.WebsiteOwner, int.Parse(autoId))) > 0)
            {
                apiResp.status = true;
                apiResp.msg    = "ok";
                int reviewCount = bllReview.GetReviewCount(BLLJIMP.Enums.ReviewTypeKey.AppointmentComment, model.ForeignkeyId, model.UserId);
                bllJuActivity.Update(new JuActivityInfo(), string.Format(" CommentCount={0} AND CommentAndReplayCount='{0}' ", reviewCount), string.Format(" JuActivityID={0}", model.ForeignkeyId));
            }
            else
            {
                apiResp.msg  = "删除评论失败";
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
            }
            bllReview.ContextResponse(context, apiResp);
        }
コード例 #2
0
ファイル: ReviewHandler.ashx.cs プロジェクト: uvbs/mmp
        //UserInfo currentUserInfo;

        //public void ProcessRequest(HttpContext context)
        //{
        //    context.Response.ContentType = "text/plain";
        //    context.Response.Expires = 0;
        //    string result = "false";
        //    try
        //    {
        //        currentUserInfo = bllUser.GetCurrentUserInfo();

        //        if (currentUserInfo == null)
        //        {
        //            resp.Status = (int)APIErrCode.UserIsNotLogin;
        //            resp.Msg = "用户未登录";
        //            result = Common.JSONHelper.ObjectToJson(resp);
        //            return;
        //        }

        //        string action = context.Request["Action"];
        //        switch (action)
        //        {
        //            case "GetReviewList":
        //                result = GetReviewList(context);
        //                break;
        //            case "DelReview":
        //                result = DelReview(context);
        //                break;
        //            case "Add":
        //                result = Add(context);
        //                break;
        //            case "ReplyList":
        //                result = ReplyList(context);
        //                break;
        //            case "DeleteReply":
        //                result = DeleteReply(context);
        //                break;
        //            case "UpdateReplyStatus":
        //                result = UpdateReplyStatus(context);
        //                break;
        //            case "UpdateReviewConfig":
        //                result = UpdateReviewConfig(context);
        //                break;
        //            case "Delete":
        //                result = Delete(context);
        //                break;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        resp.Status = -1;
        //        resp.Msg = ex.Message;
        //        result = Common.JSONHelper.ObjectToJson(resp);

        //    }
        //    context.Response.Write(result);
        //}


        /// <summary>
        /// 评论列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetReviewList(HttpContext context)
        {
            try
            {
                int pageIndex = Convert.ToInt32(context.Request["page"]),

                    pageSize = Convert.ToInt32(context.Request["rows"]);

                string actId = context.Request["actId"];

                string keyword = context.Request["keyword"];

                string Pfolder = context.Request["Pfolder"];

                string status = context.Request["status"];

                string foreignkeyId = context.Request["foreignkeyId"];

                string type = context.Request["type"];

                if (string.IsNullOrEmpty(Pfolder))
                {
                    type = "话题";
                }
                else
                {
                    if (Pfolder == "ArticleManage")
                    {
                        type = "";
                    }
                    if (Pfolder == "OrderComment")
                    {
                        type = "OrderComment";
                    }
                }

                if (pageIndex == 0)
                {
                    pageIndex = 1;
                }

                if (pageSize == 0)
                {
                    pageSize = int.MaxValue;
                }
                int totalCount             = 0;
                List <ReviewInfo> dataList = bllReview.GetActReviewList(out totalCount, pageIndex, pageSize, foreignkeyId, keyword, null, type, actId, status);

                List <ResponModel> returnList = new List <ResponModel>();

                foreach (var item in dataList)
                {
                    ResponModel model = new ResponModel();
                    model.id            = item.ReviewMainId;
                    model.title         = item.ReviewTitle;
                    model.content       = item.ReviewContent;
                    model.comment_img   = item.CommentImg;
                    model.foreignkey_id = item.ForeignkeyId;
                    model.status        = item.AuditStatus;
                    model.reply_count   = bll.GetCount <ReplyReviewInfo>(string.Format(" ReviewID={0}", item.AutoId));
                    model.review_id     = item.AutoId;
                    model.ex1           = item.Expand1;
                    if (type == "OrderComment")
                    {
                        model.name = item.UserName;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(item.UserId))
                        {
                            model.name = bllUser.GetUserDispalyName(item.UserId);
                        }
                    }
                    if (type != "OrderComment")
                    {
                        model.rpyNum = bllReview.GetReviewCount(item.ReviewMainId.ToString());
                    }
                    model.type = item.ReviewType;
                    returnList.Add(model);
                }
                return(Common.JSONHelper.ObjectToJson(new
                {
                    rows = returnList,
                    total = totalCount
                }));
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }