コード例 #1
0
        private static void ValidateOrderListTest(MarketplaceAPIService serviceClient, HeaderMessage headerMessage)
        {
            ValidateOrderListMessage validateOrderListMessage = new ValidateOrderListMessage();

            validateOrderListMessage.OrderList = new ValidateOrder[] { new ValidateOrder()
                                                                       {
                                                                           CarrierName   = "CarrierName",
                                                                           OrderLineList = new ValidateOrderLine[]
                                                                           {
                                                                               new ValidateOrderLine()
                                                                               {
                                                                                   AcceptationState = AcceptationStateEnum.AcceptedBySeller, ProductCondition = ProductConditionEnum.New, SellerProductId = "CHI8003970895435"
                                                                               },
                                                                               new ValidateOrderLine()
                                                                               {
                                                                                   AcceptationState = AcceptationStateEnum.AcceptedBySeller, ProductCondition = ProductConditionEnum.New, SellerProductId = "DOD3592668078117"
                                                                               },
                                                                           },
                                                                           OrderNumber    = "1109029051W54OU",
                                                                           OrderState     = OrderStateEnum.AcceptedBySeller,
                                                                           TrackingNumber = "TrackingNumber",
                                                                           TrackingUrl    = "TrackingNumber"
                                                                       } };

            var validationResultMessage = serviceClient.ValidateOrderList(headerMessage, validateOrderListMessage);
        }
コード例 #2
0
        public ValidateOrderListRequest(GetOrderListMessage MyGetOrderListMessage)
        {
            _ValidateOrderListMessage = new ValidateOrderListMessage();
            int i = 0;

            foreach (Order MyOrder in MyGetOrderListMessage._OrderListMessage.Result.OrderList)
            {
                ValidateOrder MyValidateOrder = new ValidateOrder();
                MyValidateOrder.CarrierName    = "CarrierName";
                MyValidateOrder.TrackingNumber = "TrackingNumber";
                MyValidateOrder.TrackingUrl    = "TrackingUrl";
                MyValidateOrder.OrderNumber    = MyOrder.OrderNumber;
                int j = 0;
                foreach (OrderLine MyOrderLine in MyOrder.OrderLineList)
                {
                    ValidateOrderLine MyValidateOrderLine = new ValidateOrderLine();
                    MyValidateOrderLine.SellerProductId  = MyOrderLine.SellerProductId;
                    MyValidateOrderLine.ProductCondition = (ProductConditionEnum)MyOrderLine.ProductCondition;
                    MyValidateOrder.OrderLineList[j]     = MyValidateOrderLine;
                }

                _ValidateOrderListMessage.OrderList[i] = MyValidateOrder;
            }
            _Token = MyGetOrderListMessage._Token;
        }
コード例 #3
0
 public ValidateOrderListRequest()
 {
     _ValidateOrderListMessage = new ValidateOrderListMessage();
 }
コード例 #4
0
        public async Task <ActionResult> ValidateOrderListResponse(ValidateOrderListRequest MyRequest)
        {
            List <ValidateOrder>     ListOfValidateOrder        = new List <ValidateOrder>();
            ValidateOrderListMessage MyValidateOrderListMessage = new ValidateOrderListMessage();

            //Order Mass Update
            if (Request.Form.Files[0].Length > 0)
            {
                // full path to file in temp location
                var           filePath = Path.GetTempFileName();
                List <string> LineList = new List <string>();
                foreach (var formFile in Request.Form.Files)
                {
                    if (formFile.Length > 0 && formFile.FileName.EndsWith(".csv"))
                    {
                        List <string> OrderNumberList      = new List <string>();
                        List <string> SellerProductIdList  = new List <string>();
                        List <string> OrderStateList       = new List <string>();
                        List <string> AcceptationStateList = new List <string>();
                        List <string> ProductConditionList = new List <string>();
                        List <string> TrackingUrlList      = new List <string>();
                        List <string> TrackingIdList       = new List <string>();
                        List <string> CarrierList          = new List <string>();
                        string        strLine = "";
                        using (var stream = new FileStream(filePath, FileMode.Create))
                        {
                            await formFile.CopyToAsync(stream);
                        }
                        using (StreamReader sr = new StreamReader(filePath, Encoding.UTF8))
                        {
                            while ((strLine = sr.ReadLine()) != null)
                            {
                                string[] param = strLine.Split(';');
                                if (param[0] != "OrderNumber" && param[2] != "NULL")
                                {
                                    OrderNumberList.Add(param[0]);
                                    OrderStateList.Add(param[1]);
                                    SellerProductIdList.Add(param[2]);
                                    ProductConditionList.Add(param[3]);
                                    AcceptationStateList.Add(param[4]);
                                    CarrierList.Add(param[5]);
                                    if (param.Length > 6)
                                    {
                                        TrackingIdList.Add(param[6]);
                                    }
                                    if (param.Length > 7)
                                    {
                                        TrackingUrlList.Add(param[7]);
                                    }
                                }
                            }
                        }
                        for (int i = 0; i < SellerProductIdList.Count; i++)
                        {
                            string strOrderNumber      = OrderNumberList.ElementAt(i).Replace("  ", string.Empty);
                            string strOrderState       = OrderStateList.ElementAt(i).Replace("  ", string.Empty);
                            string strSellerProductid  = SellerProductIdList.ElementAt(i).Replace("  ", string.Empty);
                            string strAcceptationState = AcceptationStateList.ElementAt(i).Replace("  ", string.Empty);
                            string strProductCondition = ProductConditionList.ElementAt(i).Replace("  ", string.Empty);
                            string strCarrierName      = CarrierList.ElementAt(i).Replace("  ", string.Empty);
                            string strTrackingId       = TrackingIdList.ElementAt(i).Replace("  ", string.Empty);
                            string strTrackingUrl      = TrackingUrlList.ElementAt(i).Replace("  ", string.Empty);

                            if (ListOfValidateOrder.Where(p => p.OrderNumber == strOrderNumber).ToList().Count > 0)
                            {
                                int j = ListOfValidateOrder.First(p => p.OrderNumber == strOrderNumber).OrderLineList.Where(q => q != null).ToList().Count;
                                //on vérifie que la ligne  commande n'ai pas déjà été rajoutée à la commande
                                if (ListOfValidateOrder.First(p => p.OrderNumber == strOrderNumber).OrderLineList.Where(q => q != null).Where(r => r.SellerProductId == strSellerProductid).ToList().Count == 0)
                                {
                                    ListOfValidateOrder.First(o => o.OrderNumber == strOrderNumber).OrderLineList[j] = new ValidateOrderLine()
                                    {
                                        SellerProductId  = strSellerProductid,
                                        AcceptationState = (AcceptationStateEnum)Enum.Parse(typeof(AcceptationStateEnum), strAcceptationState),
                                        ProductCondition = (ProductConditionEnum)Enum.Parse(typeof(ProductConditionEnum), strProductCondition)
                                    }
                                }
                                ;
                            }
                            //La commande n'a pas déjà été rajoutée à la requête
                            else
                            {
                                ListOfValidateOrder.Add(new ValidateOrder()
                                {
                                    OrderNumber    = strOrderNumber,
                                    OrderState     = (OrderStateEnum)Enum.Parse(typeof(OrderStateEnum), strOrderState),
                                    TrackingNumber = strTrackingId,
                                    TrackingUrl    = strTrackingUrl,
                                    CarrierName    = strCarrierName,
                                    OrderLineList  = new ValidateOrderLine[OrderNumberList.Count(n => n == strOrderNumber)]
                                });
                                ListOfValidateOrder.First(o => o.OrderNumber == OrderNumberList[i]).OrderLineList[0] = new ValidateOrderLine {
                                    SellerProductId  = SellerProductIdList[i],
                                    AcceptationState = (AcceptationStateEnum)Enum.Parse(typeof(AcceptationStateEnum), AcceptationStateList[i]),
                                    ProductCondition = (ProductConditionEnum)Enum.Parse(typeof(ProductConditionEnum), ProductConditionList[i])
                                };
                            }
                        }
                    }
                }
            }
            //Order unit Update
            else
            {
                string[] OrderNumberList      = Request.Form["OrderNumber[]"].ToArray();
                string[] SellerProductIdList  = Request.Form["SellerProductid[]"].ToArray();
                string[] OrderStateList       = Request.Form["OrderState[]"].ToArray();
                string[] AcceptationStateList = Request.Form["AcceptationState[]"].ToArray();
                string[] ProductConditionList = Request.Form["ProductCondition[]"].ToArray();
                string[] TrackingUrlList      = Request.Form["TrackingUrl[]"].ToArray();
                string[] TrackingIdList       = Request.Form["TrackingId[]"].ToArray();
                string[] CarrierList          = Request.Form["CarrierName[]"].ToArray();
                for (int i = 0; i < SellerProductIdList.Length; i++)
                {
                    //La commande a déjà été rajoutée à la requête
                    if (ListOfValidateOrder.Where(p => p.OrderNumber == OrderNumberList[i]).ToList().Count > 0)
                    {
                        if (ListOfValidateOrder.First(o => o.OrderNumber == OrderNumberList[i]).OrderLineList == null)
                        {
                            ListOfValidateOrder.First(o => o.OrderNumber == OrderNumberList[i]).OrderLineList = new ValidateOrderLine[SellerProductIdList.Length];
                        }

                        int j = ListOfValidateOrder.First(p => p.OrderNumber == OrderNumberList[i]).OrderLineList.Where(q => q != null).ToList().Count;
                        //on vérifie que la ligne  commande n'ai pas déjà été rajoutée à la commande
                        if (ListOfValidateOrder.First(p => p.OrderNumber == OrderNumberList[i]).OrderLineList.Where(q => q != null).Where(r => r.SellerProductId == SellerProductIdList[i]).ToList().Count == 0)
                        {
                            ListOfValidateOrder.First(o => o.OrderNumber == OrderNumberList[i]).OrderLineList[j] = new ValidateOrderLine()
                            {
                                SellerProductId  = SellerProductIdList[i],
                                AcceptationState = (AcceptationStateEnum)Enum.Parse(typeof(AcceptationStateEnum), AcceptationStateList[0]),
                                ProductCondition = (ProductConditionEnum)Enum.Parse(typeof(ProductConditionEnum), ProductConditionList[0])
                            }
                        }
                        ;
                    }
                    //La commande n'a pas déjà été rajoutée à la requête
                    else
                    {
                        ListOfValidateOrder.Add(new ValidateOrder()
                        {
                            OrderNumber    = OrderNumberList[i],
                            OrderState     = (OrderStateEnum)Enum.Parse(typeof(OrderStateEnum), OrderStateList[i]),
                            TrackingNumber = TrackingIdList[i],
                            TrackingUrl    = TrackingUrlList[i],
                            CarrierName    = CarrierList[i],
                            OrderLineList  = new ValidateOrderLine[50]
                        });
                        ListOfValidateOrder.First(o => o.OrderNumber == OrderNumberList[i]).OrderLineList[0] = new ValidateOrderLine {
                            SellerProductId  = SellerProductIdList[i],
                            AcceptationState = (AcceptationStateEnum)Enum.Parse(typeof(AcceptationStateEnum), AcceptationStateList[i]),
                            ProductCondition = (ProductConditionEnum)Enum.Parse(typeof(ProductConditionEnum), ProductConditionList[i])
                        };
                    }
                }
            }
            int k = 0;

            MyRequest._ValidateOrderListMessage.OrderList = new ValidateOrder[ListOfValidateOrder.Where(o => o.OrderNumber != "OrderNumber").Count()];
            foreach (ValidateOrder v in ListOfValidateOrder.Where(o => o.OrderNumber != "OrderNumber"))
            {
                MyRequest._ValidateOrderListMessage.OrderList[k] = new ValidateOrder()
                {
                    OrderNumber    = v.OrderNumber,
                    OrderState     = v.OrderState,
                    CarrierName    = v.CarrierName,
                    TrackingNumber = v.TrackingNumber,
                    TrackingUrl    = v.TrackingUrl,
                    OrderLineList  = v.OrderLineList.Where(o => o != null).ToArray()
                };
                k++;
            }
            MyRequest.GetHeaderMessage();
            SetSessionData(MyRequest);
            ValidateOrderListResponse MyValidateOrderListResponse = new ValidateOrderListResponse();

            return(View(await MyValidateOrderListResponse.GetMessage(MyRequest)));
        }