示例#1
0
        public ActionResult AddGoods(int?id)
        {
            int          pid   = id ?? 0;
            ProductModel model = new ProductModel();

            ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;

            bindOptions.BindProductPicsCount = 0;
            bindOptions.ProductBindType      = ProductBindType.Author | ProductBindType.Pics;

            if (pid > 0)
            {
                ProductServiceClient        client  = new ProductServiceClient();
                AdvancedResult <ProProduct> product = client.GetBBInfo(pid);
                if (product.Error == DataStructure.AppError.ERROR_SUCCESS)
                {
                    model.Bind(product.Data, bindOptions);
                }
                foreach (var item in model.Pics)
                {
                    item.DisplaySeting(126, 126);
                }
            }
            else
            {
                model        = new ProductModel();
                model.IsWash = true;
            }

            ViewBag.ProductJson = JsonHelper.Serialize(model);

            return(View("~/Views/User/AddGoods.cshtml", model));
        }
示例#2
0
        public ActionResult Detail(int id)
        {
            ViewBag.ItemId = id;
            ProductServiceClient client = new ProductServiceClient();
            AdvancedResult <List <ProProduct> > response = client.LoadInterestingBB(CurrentToken);

            List <ProductModel> interestings = new List <ProductModel>();

            if (response.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                response.Data = response.Data ?? new List <ProProduct>();
                response.Data = response.Data.Take(4).ToList();

                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.ProductBindType = bindOptions.ProductBindType | ProductBindType.Pics;

                foreach (var p in response.Data)
                {
                    interestings.Add(new ProductModel().Bind(p, bindOptions));
                }
            }

            ProductModel productModel           = new ProductModel();
            AdvancedResult <ProProduct> product = client.GetBBInfo(id);

            if (product.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.BindProductPicsCount = 0;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.Author | ProductBindType.Pics;
                bindOptions.UserBindType         = bindOptions.UserBindType | UserBindType.PubProductCount;
                productModel.Bind(product.Data, bindOptions);

                client.SetBBPostViewNum(product.Data.Pid);
            }

            ViewBag.Product   = productModel;
            ViewBag.Interests = interestings;

            return(View("~/Views/Trade/Detail.cshtml"));
        }
示例#3
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);
        }
示例#4
0
        public JsonResult GetGoodsDetail()
        {
            int id = 0;

            int.TryParse(Request["id"], out id);
            ProductServiceClient          client     = new ProductServiceClient();
            AdvancedResult <ProProduct>   dbresponse = client.GetBBInfo(id);
            AdvancedResult <ProductModel> response   = new AdvancedResult <ProductModel>();

            response.Error        = dbresponse.Error;
            response.ErrorMessage = dbresponse.ErrorMessage;
            response.ExMessage    = dbresponse.ExMessage;
            if (dbresponse.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                //bindOptions.ProductItemBindType = bindOptions.ProductItemBindType | ProductItemBindType.Product;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.Author | ProductBindType.ReplyCount | ProductBindType.Pics;
                bindOptions.BindProductPicsCount = 0;
                response.Data = new ProductModel().Bind(dbresponse.Data, bindOptions);
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }