private void GetAlternativeRecipe(DayPlan day)
    {
        day.Recipe = day.Recipe !.Name == day.RecipeAlternatives?.Last().Name
                                                                        ? day.RecipeAlternatives?[0]
                                                                        : day.RecipeAlternatives?.SkipWhile(x => x.Name != day.Recipe.Name).Skip(1).First();

        day.Garnish = day.Recipe !.Garnishes.RandomElement();
    }
    private void GetAlternativeGarnish(DayPlan day)
    {
        DayPlanRecipe?lastGarnish = day.Garnish;

        do
        {
            day.Garnish = day.Recipe !.Garnishes.RandomElement();
        }while (day.Garnish == lastGarnish);
    }
Beispiel #3
0
        public Cocktail(Cocktails id, string name, string color, bool ice, Vessels vessel, PrepMethods prepMethod, Garnishes garnish,
                        params CocktailIngredient[] recipe)
        {
            Id   = id;
            Name = name;
            Ice  = ice;

            Vessel     = vessel;
            PrepMethod = prepMethod;
            Garnish    = garnish;

            Recipe = recipe;

            Color = color;
        }
Beispiel #4
0
    /// <summary>
    /// Initializes a new instance of the <see cref="RecipeSelectViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="recipeService">Recipe service dependency.</param>
    /// <param name="recipeFiltrator">RecipeFiltrator service dependency.</param>
    /// <param name="day">Day, which settings will be user for filtering.</param>
    /// <param name="garnishSelect">Select garnish.</param>
    public RecipeSelectViewModel(DialogService dialogService,
                                 RecipeService recipeService,
                                 RecipeFiltrator recipeFiltrator,
                                 DayPlan?day        = null,
                                 bool garnishSelect = false)
        : base(dialogService)
    {
        this.recipeService   = recipeService;
        this.recipeFiltrator = recipeFiltrator;
        if (garnishSelect && day != null)
        {
            List <Guid> possibleGarnishes = day.Recipe !.Garnishes.ConvertAll(x => x.ID);
            recipies = recipeService.GetProjected <RecipeListViewDto>(x => possibleGarnishes.Contains(x.ID));
        }
        else
        {
            recipies = recipeService.GetProjected <RecipeListViewDto>();
        }

        // CollectionViewSource must be created on UI thread
        Application.Current.Dispatcher.Invoke(() => RecipiesSource = new CollectionViewSource()
        {
            Source = recipies
        });

        if (!garnishSelect && day != null)
        {
            // TODO: Prepare string separately
            var sb = new StringBuilder();

            if (day.NeededDishTypes?.Any(x => x.IsChecked && x.CanBeRemoved) == true)
            {
                foreach (TagEdit dishType in day.NeededDishTypes)
                {
                    sb.Append(Consts.TagSymbol)
                    .Append('"')
                    .Append(dishType.Name)
                    .Append('"');

                    if (dishType != day.NeededDishTypes.Last())
                    {
                        sb.Append(" or ");
                    }
                }
            }

            if (day.NeededMainIngredients?.Any(x => x.IsChecked && x.CanBeRemoved) == true)
            {
                bool needEnd = false;
                if (sb.Length > 0)
                {
                    if (day.NeededDishTypes?.Count > 1)
                    {
                        sb.Insert(0, '(')
                        .Append(')');
                    }

                    sb.Append(" and ");

                    if (day.NeededMainIngredients.Count > 1)
                    {
                        sb.Append('(');
                        needEnd = true;
                    }
                }

                foreach (TagEdit mainIngredient in day.NeededMainIngredients)
                {
                    sb.Append(Consts.TagSymbol)
                    .Append('\"')
                    .Append(mainIngredient.Name)
                    .Append('\"');

                    if (mainIngredient != day.NeededMainIngredients.Last())
                    {
                        sb.Append(" or ");
                    }
                }

                if (needEnd)
                {
                    sb.Append(')');
                }
            }

            FilterText = sb.ToString();
        }
    }
Beispiel #5
0
 public Garnish(Garnishes id, string name)
 {
     Id   = id;
     Name = name;
 }
Beispiel #6
0
 public Cocktail(Cocktails id, string name, string color, Vessels vessel, PrepMethods prepMethod, Garnishes garnish,
                 params CocktailIngredient[] recipe) : this(id, name, color, false, vessel, prepMethod, garnish, recipe)
 {
 }