private void updateCache()
        {
            Dictionary <long, long> topDictionary   = new Dictionary <long, long>();
            IEnumerable <Order>     ordersInProgres = OrderInformationsService.GetUndeliveredOrders();

            foreach (Order order in ordersInProgres)
            {
                foreach (OrderEntry orderEntity in order.OrderEntries)
                {
                    if (topDictionary.ContainsKey(orderEntity.BookType.Id))
                    {
                        topDictionary[orderEntity.BookType.Id] += orderEntity.Amount;
                    }
                    else
                    {
                        topDictionary.Add(orderEntity.BookType.Id, orderEntity.Amount);
                    }
                }
            }

            int number = Math.Min(quantity, topDictionary.Count);

            List <long> topList = new List <long>();

            foreach (var pair in topDictionary.OrderBy(i => i.Value).Take(number))
            {
                topList.Add(pair.Key);
            }

            if (number < quantity)
            {
                fillUpWithRandom(topList);
            }

            SuggestionCache newSuggestionCache = new SuggestionCache();

            newSuggestionCache.BookList       = topList;
            newSuggestionCache.GenerationTime = DateTime.Now;

            SuggestionCache = newSuggestionCache;
        }
Exemplo n.º 2
0
 public IEnumerable <Order> GetUnrealizedOrders()
 {
     return(OrderInformationsService.GetUndeliveredOrders());
 }