コード例 #1
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);
        }