コード例 #1
0
 public void SaveItemHistory(string currStore, CartItem currItem, string path)
 {
     using (var package = new ExcelPackage())
     {
         List <string> storeId      = currStore.Split('-').ToList();
         StoreHeader   storeData    = StoreQuery.GetStoreHeader(Convert.ToInt64(storeId[0]), Convert.ToInt32(storeId[1]));
         var           priceHist    = HistItemQuery.GetItemHistory(currItem, storeData);
         var           workbook     = package.Workbook;
         var           worksheet    = workbook.Worksheets.Add("ItemHistory");
         int           currRow      = 1;
         var           dateHeadCell = worksheet.Cells[currRow, 1];
         dateHeadCell.Value = "Date";
         var priceHeadCell = worksheet.Cells[currRow, 2];
         priceHeadCell.Value = "Price";
         foreach (var record in priceHist)
         {
             currRow++;
             var dateCell = worksheet.Cells[currRow, 1];
             dateCell.Value = record.Key.Date.ToString("dd/MM/yyyy");
             var priceCell = worksheet.Cells[currRow, 2];
             priceCell.Value = record.Value;
         }
         var chart  = worksheet.Drawings.AddChart("chart", eChartType.ColumnStacked);
         var series = chart.Series.Add($"B2:B{currRow}", $"A2:A{currRow}");
         series.Header = "Price";
         package.SaveAs(new System.IO.FileInfo(path));
     }
 }
コード例 #2
0
        public List <KeyValuePair <string, string> > GetItemStores(CartItem currItem)
        {
            var storeIds  = HistItemQuery.GetStores(currItem);
            var storeData = storeIds.Select(s => StoreQuery.GetStoreHeader(s.Key, s.Value)).ToList();

            return(storeData.Select(i => new KeyValuePair <string, string>($"{i.ChainId}-{i.StoreId}", $"{i.ChainName}-{i.StoreName}")).ToList());
        }
コード例 #3
0
 public PricingLogicManager()
 {
     User          = string.Empty;
     AccQuery      = new AccountQuery();
     ItemQuery     = new ItemQuery();
     StoreQuery    = new StoreQuery();
     HistItemQuery = new HistItemQuery();
     userCart      = new Cart();
 }
コード例 #4
0
 public List <UpdatedCart> CalculateTotal(List <string> stores)
 {
     UpdatedCarts = new List <UpdatedCart>();
     foreach (var item in stores)
     {
         List <string> storeId   = item.Split('-').ToList();
         StoreHeader   storeData = StoreQuery.GetStoreHeader(Convert.ToInt64(storeId[0]), Convert.ToInt32(storeId[1]));
         UpdateCart(storeData);
     }
     return(UpdatedCarts);
 }
コード例 #5
0
        public List <UpdatedCart> CalculateTotal(List <long> chains, string location, int productsToFetch)
        {
            UpdatedCarts = new List <UpdatedCart>();
            List <StoreHeader> markedStores         = new List <StoreHeader>();
            List <KeyValuePair <long, int> > idData = new List <KeyValuePair <long, int> >();
            int uniqueFetchs;

            if (chains.Count >= productsToFetch)
            {
                uniqueFetchs = productsToFetch;
            }
            else
            {
                uniqueFetchs = chains.Count;
            }
            for (int i = 0; i < uniqueFetchs; i++)
            {
                idData = ItemQuery.GetCheapestStore(new List <long>()
                {
                    chains[i]
                }, userCart.Items, location, markedStores, 1);
                if (idData.Count > 0)
                {
                    StoreHeader storeData = StoreQuery.GetStoreHeader(idData.First().Key, idData.First().Value);
                    UpdateCart(storeData);
                    markedStores.Add(storeData);
                }
            }
            if (UpdatedCarts.Count > 0 &&
                UpdatedCarts.Count < productsToFetch)
            {
                idData = ItemQuery.GetCheapestStore(chains, userCart.Items, location, markedStores, productsToFetch - UpdatedCarts.Count);
                foreach (var id in idData)
                {
                    StoreHeader storeData = StoreQuery.GetStoreHeader(id.Key, id.Value);
                    UpdateCart(storeData);
                }
            }
            return(UpdatedCarts.OrderBy(c => c.TotalPrice).ToList());
        }
コード例 #6
0
        public List <KeyValuePair <string, string> > GetStores(List <long> chains, string location)
        {
            List <StoreHeader> storeData = StoreQuery.GetStores(chains, location);

            return(storeData.Select(i => new KeyValuePair <string, string>($"{i.ChainId}-{i.StoreId}", $"{i.ChainName}-{i.StoreName}")).ToList());
        }
コード例 #7
0
 public List <string> GetLocations(List <long> chains)
 {
     return(StoreQuery.GetLocations(chains));
 }
コード例 #8
0
 public List <KeyValuePair <long, string> > GetChains()
 {
     return(StoreQuery.GetAllChains());
 }