コード例 #1
0
        public async static Task <Product> CreateProductIfNotExists(string id)
        {
            var     getRequest = new ProductGetRequest(id);
            Product getProduct = null;

            try
            {
                var getResponse = await TestHarness.client().Execute(getRequest);

                getProduct = getResponse.Result <Product>();
            }
            catch (PayPalHttp.HttpException httpEx)
                when(httpEx.GetError() != null && httpEx.GetError().Name == "RESOURCE_NOT_FOUND")
                {
                    getProduct = null;
                }
            if (getProduct == null)
            {
                var request = new ProductsCreateRequest();
                request.Prefer("return=representation");
                request.RequestBody(buildRequestBody(id));
                var createResponse = await TestHarness.client().Execute(request);

                getProduct = createResponse.Result <Product>();
            }
            return(getProduct);
        }
コード例 #2
0
        public ProductGetResponse Get(ProductGetRequest request)
        {
            var response = new ProductGetResponse();

            _facade.Get(request.Id);
            return(response);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: BuiltCloud/Built
 public override Task <ProductGetResponse> Get(ProductGetRequest request, ServerCallContext context)
 {
     if (store.ContainsKey(request.ProductId))
     {
         return(Task.FromResult(store[request.ProductId]));
     }
     return(Task.FromResult(default(ProductGetResponse)));
 }
コード例 #4
0
        public static Product GetProduct(string itemId)
        {
            ITopClient        client = new DefaultTopClient(TaobaoUrl, AppKey, AppSecret);
            ProductGetRequest req    = new ProductGetRequest();

            req.Fields    = @"name,cat_name,price,pic_url,sale_num,vertical_market,sell_pt";
            req.ProductId = itemId.TryLongParse();
            ProductGetResponse response = client.Execute(req);

            return(response.Product);
        }
コード例 #5
0
 public IActionResult Get(int id)
 {
     try
     {
         var request = new ProductGetRequest()
         {
             id = id
         };
         return(Ok(_mediator.Send(request)));
     }
     catch (Exception ex)
     {
         return(BadRequest("Falha ao localizar Produtos" + ex.ToString()));
     }
 }
コード例 #6
0
        public async Task TestProductGetDetailsRequest()
        {
            var product = await ProductsCreateTest.CreateProductIfNotExists(ProductsCreateTest.ProductId1);

            ProductGetRequest request = new ProductGetRequest(product.Id);

            var response = await TestHarness.client().Execute(request);

            Assert.Equal(200, (int)response.StatusCode);

            Product retrievedProduct = response.Result <Product>();

            Assert.NotNull(retrievedProduct);

            Assert.NotNull(retrievedProduct.Links);
        }
コード例 #7
0
        public async Task <IProductState> GetAsync(string productId)
        {
            IProductState state         = null;
            var           idObj         = productId;
            var           uriParameters = new ProductUriParameters();

            uriParameters.Id = idObj;

            var req = new ProductGetRequest(uriParameters);

            var resp = await _ramlClient.Product.Get(req);

            ProductProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToProductState();
            return(state);
        }
コード例 #8
0
ファイル: OurProductFactory.cs プロジェクト: ttcp112/CSC
        public List <ProductApplyAdditionModels> ProductGetProductApplyAddition(string AdditionID, string CustomerID)
        {
            List <ProductApplyAdditionModels> listData = new List <ProductApplyAdditionModels>();

            try
            {
                ProductGetRequest paraBody = new ProductGetRequest();
                paraBody.ID         = CustomerID;
                paraBody.AdditionID = AdditionID;
                NSLog.Logger.Info("ProductGetProductApplyAddition Request: ", paraBody);
                var     result     = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ClientSiteOurProductGetProductApplyAddition, null, paraBody);
                dynamic data       = result.Data;
                var     lstDataRaw = data["ListProduct"];
                var     lstObject  = JsonConvert.SerializeObject(lstDataRaw);
                listData = JsonConvert.DeserializeObject <List <ProductApplyAdditionModels> >(lstObject);
                if (listData != null && listData.Any())
                {
                    // Convert datetime
                    listData.ForEach(xy =>
                    {
                        xy.BoughtTime = CommonHelper.ConvertToLocalTime(xy.BoughtTime);
                        if (xy.ExpiredTime.HasValue)
                        {
                            xy.ExpiredTime = CommonHelper.ConvertToLocalTime(xy.ExpiredTime.Value);
                        }
                        if (xy.ListProduct != null && xy.ListProduct.Any())
                        {
                            xy.ListProduct.ForEach(xyz =>
                            {
                                xyz.BoughtTime = CommonHelper.ConvertToLocalTime(xyz.BoughtTime);
                                if (xyz.ExpiredTime.HasValue)
                                {
                                    xyz.ExpiredTime = CommonHelper.ConvertToLocalTime(xyz.ExpiredTime.Value);
                                }
                            });
                        }
                    });
                }
                NSLog.Logger.Info("ProductGetProductApplyAddition", listData);
                return(listData);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("ProductGetProductApplyAddition_Fail", e);
                return(listData);
            }
        }
コード例 #9
0
        /// <summary>
        /// 获取产品信息
        /// </summary>
        /// <returns></returns>
        public ProductGetResponse GetProducts(ProductGetRequest request)
        {
            ProductGetResponse response = new ProductGetResponse();

            var list = ProductDal.Instance.GetProducts(request.Query);

            //判断是否有数据
            if (list.Count <= 0)
            {
                //给返回对象属性赋值
                response.Status  = false;
                response.Message = "获取产品信息失败,请检查网络问题";
            }
            else
            {
                //给返回对象赋值
                response.Products = list;
                response.Message  = $"获取产品信息成功,共{list.Count}条数据";
            }
            return(response);
        }
コード例 #10
0
ファイル: OurProductFactory.cs プロジェクト: ttcp112/CSC
        /// <summary>
        /// Function [GetListData]
        /// CustomerID for Reseller
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <param name="SearchString"></param>
        /// <param name="ProductType"></param>
        /// <param name="ListCateID"></param>
        /// <param name="ListProductID"></param>
        /// <param name="ProductID"></param>
        /// <param name="ListType"></param>
        /// <returns></returns>
        public List <OurProDuctsModel> GetListData(string CustomerID, string SearchString = null, int ProductType = 0,
                                                   List <string> ListCateID = null, List <string> ListProductID   = null, string ProductID = null, List <int> ListType = null)
        {
            List <OurProDuctsModel> listData = new List <OurProDuctsModel>();

            try
            {
                ProductGetRequest paraBody = new ProductGetRequest();
                paraBody.ProductType   = ProductType;
                paraBody.SearchString  = SearchString;
                paraBody.ListCateID    = ListCateID;
                paraBody.ListProductID = ListProductID;
                paraBody.ListType      = ListType;
                //===Get Detail
                paraBody.ID         = ProductID;
                paraBody.CustomerID = CustomerID;

                NSLog.Logger.Info("ProductGetListData Request: ", paraBody);

                var     result     = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ClientSideOurProductGet, null, paraBody);
                dynamic data       = result.Data;
                var     lstDataRaw = data["ListProduct"];
                var     lstObject  = JsonConvert.SerializeObject(lstDataRaw);
                listData = JsonConvert.DeserializeObject <List <OurProDuctsModel> >(lstObject);

                NSLog.Logger.Info("ProductGetListData", listData);

                if (listData != null && listData.Any())
                {
                    listData = listData.OrderBy(oo => oo.Name).ThenBy(ss => ss.Sequence).ToList();
                }
                return(listData);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("ProductGetListData_Fail", e);
                return(listData);
            }
        }
コード例 #11
0
 /// <summary>
 /// 获取产品信息
 /// </summary>
 public ProductGetResponse GetProducts(ProductGetRequest request)
 {
     return(ApiRequestHelper.Post <ProductGetRequest, ProductGetResponse>(request));
 }
コード例 #12
0
 /// <summary>
 /// 获取一个产品的信息
 /// 两种方式查看一个产品详细信息: 传入product_id来查询 传入cid和props来查询
 /// </summary>
 /// <param name="fields">必填 需返回的字段列表.可选值:Product数据结构中的所有字段;多个字段之间用","分隔</param>
 /// <param name="productid">Product的id.两种方式来查看一个产品:1.传入product_id来查询 2.传入cid和props来查询</param>
 /// <param name="cid">商品类目id.调用taobao.itemcats.get获取;必须是叶子类目id,如果没有传product_id,那么cid和props必须要传</param>
 /// <param name="props">关键属性,结构:pid1:value1;pid2:value2</param>
 /// <param name="customerprops">用户自定义关键属性,结构:pid1:value1;pid2:value2,如果有型号,系列等子属性用: 隔开</param>
 /// <param name="marketid">市场ID,1为取C2C市场的产品信息, 2为取B2C市场的产品信息。 不填写此值则默认取C2C的产品信息。</param>
 /// <returns></returns>
 public static Product GetProductInfo(string fields, long? productid, long? cid, string props, string customerprops, string marketid)
 {
     ITopClient client = TopClientService.GetTopClient();
     ProductGetRequest req = new ProductGetRequest();
     req.Fields = fields;
     req.ProductId = productid;
     req.Cid = cid;
     req.Props = props;
     req.CustomerProps = customerprops;
     req.MarketId = marketid;
     ProductGetResponse response = client.Execute(req);
     return response.Product;
 }
コード例 #13
0
 public ProductGetResponse GetProducts(ProductGetRequest request)
 {
     return(ProductBll.Instance.GetProducts(request));
 }
コード例 #14
0
 /// <summary>
 /// 获取产品列表信息
 /// </summary>
 /// <returns></returns>
 public JsonResult GetProducts(ProductGetRequest getRequest)
 {
     return(Json(ProductBll.Instance.GetProducts(getRequest), JsonRequestBehavior.AllowGet));
 }
コード例 #15
0
        public async Task <ProductResource> GetByIdAsync(ProductGetRequest productRequest)
        {
            var product = await _productRepository.GetByIdAsync(productRequest.Id);

            return(new ProductResource().ToResource(product));
        }
コード例 #16
0
        public async Task <IEnumerable <ProductResource> > ListByPerson(Guid personId, [FromQuery] ProductGetRequest request)
        {
            var pageNumber = request.Page;

            pageNumber = pageNumber <= 0 ? 1 : pageNumber;

            IEnumerable <Product> productList = await _productListCommand.ListPersonProducts(personId, pageNumber);

            IEnumerable <ProductResource> productResourceList = productList.Select(p => new ProductResource
            {
                Id          = p.Id,
                Title       = p.Title,
                Brand       = p.Brand,
                Image       = p.Image,
                Price       = p.Price,
                ReviewScore = p.ReviewScore
            });

            return(productResourceList);
        }