Ejemplo n.º 1
0
        public bool IsStockMatching(string search, StockSearchItemViewModel stockItem)
        {
            if (string.IsNullOrEmpty(search))
            {
                return(false);
            }

            search = search.ToLower();
            if (StockNameExclusions.Contains(search))
            {
                return(false);
            }

            if (stockItem != null)
            {
                if (stockItem.Symbol.ToLower().StartsWith(search))
                {
                    return(true);
                }
                var words = stockItem.Name.ToLower().Split(' ').ToList();
                if (words.Any(word => word.StartsWith(search)))
                {
                    return(true);
                }
                if (stockItem.Name.ToLower().StartsWith(search))
                {
                    return(true);
                }
            }
            return(false); // if no match
        }
Ejemplo n.º 2
0
 protected void PopulateStockSearchDictionary(StockSearchItemViewModel stockItem)
 {
     if (!StockSearchDictionary.ContainsKey(stockItem.Symbol))
     {
         StockSearchDictionary.Add(stockItem.Symbol, stockItem);
     }
     //if (!StockSearchByName.ContainsKey(stockItem.NameShort))
     //{
     //    StockSearchByName.Add(stockItem.NameShort, stockItem);
     //}
 }