Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }