Esempio n. 1
0
 private List<List<ngHistoryEntry>> FindPossibleMenus(int dayOfWeek, ngHistoryModel history)
 {
     List<List<ngHistoryEntry>> groups = new List<List<ngHistoryEntry>>();
     List<ngHistoryGroupEntry> allHistoryByDate = history.GroupByDate(dayOfWeek);
     List<ngFoodItem> todayFoods = FoodManager.Inst.GetFoods(dayOfWeek);
     foreach (ngHistoryGroupEntry entry in allHistoryByDate)
     {
         if (HasFoodsInMenu(entry.Entries, todayFoods)) {
             groups.Add(entry.Entries);
         }
     }
     return groups;
 }
Esempio n. 2
0
        private static void AddHistoryEntryToModel(ngUserModel ngUser, List<ngOrderEntry> orders, int dayOfWeek)
        {
            ngHistoryModel model = HistoryManager.Inst.GetHistoryModelByUser(ngUser);
            if (null == model) {
                model = new ngHistoryModel();
                HistoryManager.Inst.AddItemAndSave(model);
                model.Email = ngUser.Email;
                model.UserId = ngUser.Id;
                model.Entries = new List<ngHistoryEntry>();
            }

            foreach (ngOrderEntry ngOrderModel in orders) {
                ngHistoryEntry entry = new ngHistoryEntry();
                entry.Date = DateTime.Now;
                entry.FoodId = ngOrderModel.FoodId;
                entry.Count = ngOrderModel.Count;
                ngFoodItem food = FoodManager.Inst.GetFoodById(dayOfWeek, ngOrderModel.FoodId);
                entry.FoodPrice = food.Price;
                model.Entries.Add(entry);
            }
        }