コード例 #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
ファイル: Default.aspx.cs プロジェクト: yxandam/BabyPlan
        protected void Button1_Click(object sender, EventArgs e)
        {
            AdvancedResult <List <GenReply> > result;
            ReplyServiceClient client = new ReplyServiceClient();

            result = client.LoadAllReplyList();
            if (result.Data != null && result.Data.Count > 0)
            {
                var list = from o in result.Data
                           select new { o.UserAccount, o.Content, o.CreateTime, o.ObjId };

                GridView1.DataSource = list;
                GridView1.DataBind();
            }
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: ReplyController.cs プロジェクト: yxandam/BabyPlan
        public JsonResult Bless()
        {
            string     wish = Request["blessContent"];
            RespResult result;

            if (string.IsNullOrEmpty(wish) || wish.Length > 200)
            {
                result           = new RespResult();
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = "心愿内容不合法!";
            }
            else
            {
                ReplyServiceClient client = new ReplyServiceClient();
                result = client.Bless(wish);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
ファイル: TradeController.cs プロジェクト: yxandam/BabyPlan
        public JsonResult AjaxReplay(int pid)
        {
            string content = Request["comment_input"];
            int    ref_id  = 0;

            int.TryParse(Request["ref_id"], out ref_id);
            RespResult response = new RespResult();

            if (string.IsNullOrEmpty(content) || content.Length < 2 || content.Length > 300)
            {
                response.Error     = AppError.ERROR_FAILED;
                response.ExMessage = "回复内容长度不合法!";
                return(Json(response));
            }

            ReplyServiceClient client = new ReplyServiceClient();

            response = client.ReplyBBPost(pid, ref_id, content, CurrentToken);
            return(Json(response));
        }
コード例 #6
0
ファイル: ReplyModel.cs プロジェクト: yxandam/BabyPlan
        public ReplyModel Bind(GenReply item, ViewModelBindOption bindOptions)
        {
            this.Id               = item.Rid;
            this.Content          = item.Content;
            this.CreateTime       = item.CreateTime;
            this.CreateTimeString = item.CreateTime.ToString("HH:mm");

            if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.Author))
            {
                UserServiceClient       client  = new UserServiceClient();
                AdvancedResult <AdUser> userRes = client.GetUserInfoByID(item.CreateId);
                if (userRes.Error == DataStructure.AppError.ERROR_SUCCESS && userRes.Data != null)
                {
                    this.Author = new UserModel().Bind(userRes.Data, bindOptions);
                }
            }

            if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.Product))
            {
                ProductServiceClient        client  = new ProductServiceClient();
                AdvancedResult <ProProduct> product = client.GetBBInfo(item.ObjId);
                if (product.Error == AppError.ERROR_SUCCESS)
                {
                    this.Product = new ProductModel().Bind(product.Data, bindOptions);
                }
            }
            if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.RefReply))
            {
                ReplyServiceClient client = new ReplyServiceClient();
                if (--bindOptions.BindRefReplyCount >= 0 && item.RefReplyId > 0)
                {
                    AdvancedResult <GenReply> refReply = client.Get(item.RefReplyId);
                    if (refReply.Error == AppError.ERROR_SUCCESS)
                    {
                        RefReply = new ReplyModel().Bind(refReply.Data, bindOptions);
                    }
                }
            }
            return(this);
        }
コード例 #7
0
ファイル: UserController.cs プロジェクト: yxandam/BabyPlan
        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));
        }