コード例 #1
0
ファイル: TradeController.cs プロジェクト: yxandam/BabyPlan
        public JsonResult GetReplys(int pid)
        {
            int pageIndex = 0;
            int pageSize  = 10;

            int.TryParse(Request["page"], out pageIndex);
            ReplyServiceClient client = new ReplyServiceClient();
            AdvancedResult <PageEntity <GenReply> > response = client.LoadReplyListByBBPostID(pid, pageIndex, pageSize);
            IList <ReplyModel> models = new List <ReplyModel>();
            string             paging = string.Empty;
            int count = 0;

            if (response.Error == AppError.ERROR_SUCCESS)
            {
                count  = response.Data.RecordsCount;
                paging = HtmlFormatHelper.GeneratePagingHtml(response.Data.PageIndex, response.Data.PageSize, response.Data.RecordsCount, "javascript:void(LoadComments({0}))", "下一页", "上一页", null, null, null);

                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.BindReplyCount    = 0;
                bindOptions.BindRefReplyCount = 1;
                bindOptions.ReplayBindType    = ReplyBindType.Author | ReplyBindType.RefReply;


                models = ReplyModel.BindList(response.Data.Items, bindOptions);
            }
            foreach (ReplyModel r in models)
            {
                if (r.Author != null && r.Author.HeadPic != null)
                {
                    r.Author.HeadPic.DisplaySeting(50, 50);
                }
            }
            return(Json(new { data = models, paging = paging, count = count }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: ProductModel.cs プロジェクト: yxandam/BabyPlan
        public ProductModel Bind(ProProduct product, ViewModelBindOption bindOptions)
        {
            this.Id          = product.Pid;
            this.Title       = product.Title;
            this.Description = product.BbInfo;
            this.IsWash      = product.IsWash;
            this.CreateTime  = product.CreateTime;
            this.ViewNum     = product.ViewNum;
            this.State       = product.State;
            this.Price       = product.Price;
            this.Sex         = product.Sex;
            this.ItemType    = product.ItemType;
            this.ItemSort    = product.ItemSort;
            this.Age         = (int)((product.MinAge + product.MaxAge) / 2.0);

            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.Pics))
            {
                this.Pics = PicModel.BindList(product.pics, bindOptions);
            }

            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.Author))
            {
                UserServiceClient       client  = new UserServiceClient();
                AdvancedResult <AdUser> userRes = client.GetUserInfoByID(product.CreateId);
                if (userRes.Error == DataStructure.AppError.ERROR_SUCCESS && userRes.Data != null)
                {
                    this.Author = new UserModel().Bind(userRes.Data, bindOptions);
                    if (!string.IsNullOrEmpty(userRes.Data.Qq))
                    {
                        this.QQ = userRes.Data.Qq;
                    }
                    if (!string.IsNullOrEmpty(userRes.Data.Mobile))
                    {
                        this.Phone = userRes.Data.Mobile;
                    }
                }
            }
            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.ReplyCount))
            {
                ReplyServiceClient client = new ReplyServiceClient();
                AdvancedResult <PageEntity <GenReply> > response = client.LoadReplyListByBBPostID(product.Pid, 0, 0);
                if (response.Error == AppError.ERROR_SUCCESS)
                {
                    this.ReplyNum = response.Data.RecordsCount;
                }
            }
            return(this);
        }