Beispiel #1
0
        public void Add(ItemCatalogData item)
        {
            if (_items.Contains(item))
            {
                return;
            }

            _items.Add(item);
        }
Beispiel #2
0
 private static void UpdateItemDetails(ItemCatalogData itemCatalogData, Dictionary <int, List <ItemFullData> > fullData)
 {
     foreach (var item in fullData)
     {
         if (itemCatalogData.ItemId != item.Key)
         {
             continue;
         }
         UpdatePrices(itemCatalogData, item);
     }
 }
Beispiel #3
0
        private static void UpdatePrices(ItemCatalogData itemCatalogData, KeyValuePair <int, List <ItemFullData> > item)
        {
            foreach (var itemFullData in item.Value)
            {
                //Update catalog from full data
                double price;
                double.TryParse(itemFullData.ItemPrice, out price);

                if (!itemCatalogData.PricesByChainName.ContainsKey(itemFullData.ChainName))
                {
                    itemCatalogData.PricesByChainName.Add(itemFullData.ChainName, 0);
                }

                itemCatalogData.PricesByChainName[itemFullData.ChainName] = price;
            }
        }
Beispiel #4
0
        public void Remove(ItemCatalogData item)
        {
            var categoryKey = item.Category;

            if (!_catalog.ContainsKey(categoryKey))
            {
                return;
            }

            _catalog[categoryKey].Remove(item);

            if (_catalog[categoryKey].Count == 0)
            {
                _catalog.Remove(categoryKey);
            }
        }
Beispiel #5
0
        public void Add(ItemCatalogData item)
        {
            var categoryKey = item.Category;

            /*You have made four dictionary lookup's where two would fit you just fine.
             * Consider refactoring this method.
             */

            if (!_catalog.ContainsKey(categoryKey))
            {
                _catalog.Add(categoryKey, new List <ItemCatalogData>());
            }

            if (!_catalog[categoryKey].Contains(item))
            {
                _catalog[categoryKey].Add(item);
            }
        }