private void generateWithoutCategory(List <long> list) { Dictionary <long, long> categoryDictionary = new Dictionary <long, long>(); foreach (Order order in OrderInformationsService.GetOrdersByUserId(userID)) { foreach (OrderEntry orderEntry in order.OrderEntries) { long category = orderEntry.BookType.Category.Id; if (categoryDictionary.ContainsKey(category)) { categoryDictionary[category]++; } else { categoryDictionary.Add(category, 1); } } } if (categoryDictionary.Count != 0) { var popularCategory = categoryDictionary.OrderBy(x => x.Value).First(); generateWithCategory(list, popularCategory.Key); } }
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; }
public IEnumerable <Order> GetUnrealizedOrders() { return(OrderInformationsService.GetUndeliveredOrders()); }
public IEnumerable <OrderEntry> GetOrderEntriesByOrderId(long orderId) { return(OrderInformationsService.GetOrderById(orderId).OrderEntries); }