private void InitializeData() { AvailableFood = sql.GetFood_All().ToDictionary(x => x.Id, x => x); AvailableCommonFood = AvailableFood.Where(p => p.Value.Type == GlobalConfig.common).ToDictionary(p => p.Key, p => p.Value); AvailableFavoriteFood = AvailableFood.Where(p => p.Value.Type == GlobalConfig.favorite).ToDictionary(p => p.Key, p => p.Value); AvailableCustomFood = AvailableFood.Where(p => p.Value.IsCustom == true).ToDictionary(p => p.Key, p => p.Value); AvailableRecipes = sql.GetRecipe_All().ToDictionary(x => x.Id, x => x); AvailablePlans = sql.GetPlan_All().ToDictionary(x => x.Id, x => x); }
/// <summary> /// Check the dish, if the included allergies collide with the users allergies. /// </summary> /// <param name="dish">The current dish to be analysed.</param> /// <param name="context">The message context, containing the stored allergies</param> /// <returns>Bool, if the dish contains one of the users allergies.</returns> private bool DishIncludesAllergy(AvailableFood dish, IDialogContext context) { try { var userAllergyList = context.ConversationData.Get <List <string> >("Allergies"); foreach (var allergy in userAllergyList) { if (dish.Allergen.Contains(allergy.ToLower())) { return(true); } } return(false); } catch (Exception) { return(false); } }
private int GetCaloriesForFood(AvailableFood food) => food switch {
public EatingAction(int userId, AvailableFood food) { UserId = userId; Food = food; }