示例#1
0
        private IngredientDto ConvertIngredient(RecipeIngredient arg)
        {
            if (arg == null)
            {
                return(null);
            }

            var dto = new IngredientDto
            {
                Amount   = arg.Ingredient.Amount,
                ItemName = arg.Ingredient.Item.Name
            };

            return(dto);
        }
        private Ingredient GetCreateIngredient(IngredientDto arg)
        {
            var item       = GetCreateItem(arg.ItemName);
            var ingredient = Access.Ingredients.SingleOrDefault(x => x.Item == item && x.Amount == arg.Amount);

            if (ingredient == null)
            {
                ingredient = new Ingredient {
                    Item = item, Amount = arg.Amount
                };
                Log.Debug($"Creating ingredient: {ingredient}");
            }
            else
            {
                Log.Debug($"Found ingredient: {ingredient}");
            }
            return(ingredient);
        }