Ejemplo n.º 1
0
        private void BuildApiRequest(IList selectedList, DataSet skuData, int time, int storeId, decimal euro)
        {
            var salesService = new SalesService();

            foreach (var item in selectedList)
            {
                List <SpecialPrice> specialPriceList = new List <SpecialPrice>();
                var prices = new List <SpecialPrice>();
                var sku    = (item as SpecailOrders).SKU;
                prices.AddRange(salesService.DeleteSKU(sku, storeId));
                //new MagentoSpecialPrice().DeleteSpecialPrice(prices.ToArray());

                var startDate = _startDateApi.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss");
                var endDate   = _endDateApi;
                if (endDate.Day == DateTime.Now.Day)
                {
                    endDate = endDate.AddDays(-1);
                }
                var endDateString = endDate.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss");
                for (int i = 1; i <= 13; i++)
                {
                    var size = "";
                    if (i < 10)
                    {
                        size += "00" + i;
                    }
                    else
                    {
                        size += "0" + i;
                    }
                    if (euro != 0)
                    {
                        specialPriceList.Add(salesService.BuildSpecialPriceObj((item as SpecailOrders).SKU + size,
                                                                               _specailOrdersService.GenerateEuroPrice(Convert.ToDecimal((item as SpecailOrders).Sell), euro),
                                                                               storeId,
                                                                               startDate,
                                                                               endDateString,
                                                                               Convert.ToDecimal(_adjustmentPriceApi),
                                                                               Convert.ToInt32(_adjustPricePercentageApi))
                                             );
                    }
                    else
                    {
                        specialPriceList.Add(salesService.BuildSpecialPriceObj((item as SpecailOrders).SKU + size,
                                                                               (item as SpecailOrders).Sell,
                                                                               storeId,
                                                                               startDate,
                                                                               endDateString,
                                                                               Convert.ToDecimal(_adjustmentPriceApi),
                                                                               Convert.ToInt32(_adjustPricePercentageApi))
                                             );
                    }
                }
                new MagentoSpecialPrice().UpdateSpecialPrice(specialPriceList.ToArray());
                List <DataRow> dataRows = skuData.Tables[0].AsEnumerable().Where(x => (string)x["SKU"] == (item as SpecailOrders).SKU).Distinct().ToList();


                //if (euro != 0)
                //{
                _specailOrdersService.GenerateCSVAsync(startDate, endDateString,
                                                       time,
                                                       dataRows,
                                                       Convert.ToDecimal(AdjustPriceApi), AdjustPricePercentageApi, euro);
                //}
                //else
                //{
                //    _specailOrdersService.GenerateCSVAsync(startDate, endDateString,
                //    time,
                //    dataRows,
                //    Convert.ToDecimal(AdjustPriceApi), AdjustPricePercentageApi);
                //}
            }
        }