Exemplo n.º 1
0
        public ActionResult ValidateOrderListResponse(ValidateOrderListRequest MyRequest)
        {
            string[] SellerProductIdList  = Request.Form["SellerProductid[]"].ToArray();
            string[] AcceptationStateList = Request.Form["AcceptationState[]"].ToArray();
            string[] ProductConditionList = Request.Form["ProductCondition[]"].ToArray();

            int length = SellerProductIdList.Length;
            List <ValidateOrderLine> ValidateOrderLineList = new List <ValidateOrderLine>();

            if (SellerProductIdList.GetLength(0) > 0)
            {
                foreach (string MySellerProductId in SellerProductIdList)
                {
                    ValidateOrderLine MyValidateOrderLine = new ValidateOrderLine()
                    {
                        SellerProductId  = MySellerProductId,
                        AcceptationState = (AcceptationStateEnum)Enum.Parse(typeof(AcceptationStateEnum), AcceptationStateList[0]),
                        ProductCondition = (ProductConditionEnum)Enum.Parse(typeof(ProductConditionEnum), ProductConditionList[0]),
                    };
                    ValidateOrderLineList.Add(MyValidateOrderLine);
                }
                MyRequest._ValidateOrderListMessage.OrderList[0].OrderLineList = ValidateOrderLineList.ToArray();
                MyRequest.GetHeaderMessage();
                SetSessionData(MyRequest);
            }
            return(View(new ValidateOrderListResponse(MyRequest)));
        }
        public ActionResult ValidateOrderListResponse(ValidateOrderListRequest MyRequest)
        {
            foreach (ValidateOrder vo in MyRequest._ValidateOrderListMessage.OrderList)
            {
                vo.OrderLineList = vo.OrderLineList.Where(val => val.SellerProductId.Length > 0).ToArray();
            }

            MyRequest.GetHeaderMessage();
            SetSessionData(MyRequest);
            return(View(new ValidateOrderListResponse(MyRequest)));
        }
Exemplo n.º 3
0
        public ActionResult ValidateOrderListRequest()
        {
            Request MyRequest = new ValidateOrderListRequest();

            /*  if (HttpContext.Session.GetString(SessionToken) != null)
             * {
             *    MyRequest._Login = HttpContext.Session.GetString(SessionLogin);
             *    MyRequest._Token = HttpContext.Session.GetString(SessionToken);
             *    MyRequest._EnvironmentSelected = (EnvironmentEnum)Enum.Parse(typeof(EnvironmentEnum), HttpContext.Session.GetString(SessionEnvironment));
             * }*/
            return(View(MyRequest));
        }
Exemplo n.º 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)));
        }