Esempio n. 1
0
        public BookModel Bind(ProBook book, ViewModelBindOption bindOptions)
        {
            this.Id           = book.BookId;
            this.Name         = book.BookName;
            this.BookSize     = book.BookSize;
            this.BookType     = book.BookType;
            this.Introduction = book.Introduction;
            this.CreateTime   = book.CreateTime;
            this.EditeTime    = book.EditeTime;
            this.BookCover    = book.BookCover;

            if (ContainEnumType <BookBindType>(bindOptions.BookBindType, BookBindType.Pics))
            {
                this.Pics = PicModel.BindList(book.Pics, bindOptions);
            }
            if (ContainEnumType <BookBindType>(bindOptions.BookBindType, BookBindType.Author))
            {
                UserServiceClient       client  = new UserServiceClient();
                AdvancedResult <AdUser> userRes = client.GetUserInfoByID(book.AdUserId);
                if (userRes.Error == DataStructure.AppError.ERROR_SUCCESS && userRes.Data != null)
                {
                    this.Author = new UserModel().Bind(userRes.Data, bindOptions);
                }
            }

            return(this);
        }
Esempio n. 2
0
        public IList <ProductModel> BindList(IEnumerable <ProProduct> products, ViewModelBindOption bindOptions)
        {
            List <ProductModel> models = new List <ProductModel>();

            if (products != null)
            {
                foreach (ProProduct p in products)
                {
                    models.Add(new ProductModel().Bind(p, bindOptions));
                }
            }
            return(models);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public static IList <PicModel> BindList(IList <ResPic> items, ViewModelBindOption bindOption)
        {
            List <PicModel> models = new List <PicModel>();

            if (bindOption.BindProductPicsCount < 0)
            {
                return(models);
            }
            if (items != null)
            {
                for (int i = 0, c = items.Count(); i < c; i++)
                {
                    models.Add(new PicModel().Bind(items[i]));
                    if (i + 1 == bindOption.BindProductPicsCount)
                    {
                        break;
                    }
                }
            }
            return(models);
        }
Esempio n. 5
0
        public static IList <ReplyModel> BindList(IList <GenReply> items, ViewModelBindOption bindOptions)
        {
            IList <ReplyModel> models = new List <ReplyModel>();

            if (bindOptions.BindReplyCount < 0)
            {
                return(models);
            }
            if (items != null)
            {
                for (int i = 0, c = items.Count(); i < c; i++)
                {
                    models.Add(new ReplyModel().Bind(items[i], bindOptions));
                    if (i + 1 == bindOptions.BindReplyCount)
                    {
                        break;
                    }
                }
            }
            return(models);
        }
Esempio n. 6
0
        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);
        }