Ejemplo n.º 1
0
 public static Recipe CompleteRecipeTree(MyContext ctx, Recipe recipe)
 {
     recipe.IngredientStacks = ctx.ObjectStacks.Where(o =>
                                                      o.Type == ObjectStack.StackTypes.Ingredient &&
                                                      o.IsDeleted == 0 &&
                                                      o.ParentId == recipe.Id
                                                      )
                               .AsEnumerable()
                               .Select(s =>
     {
         s.Item = IngredientService.GetIngredientById(ctx, s.ItemId);
         return(s);
     })
                               .ToList();
     return(recipe);
 }
Ejemplo n.º 2
0
        public static ObjectStack CompleteRecipeStack(MyContext ctx, ObjectStack recipeStack)
        {
            var recipe = ctx.Recipes.First(i => i.Id == recipeStack.ItemId && i.IsDeleted == 0);

            recipe.IngredientStacks = ctx.ObjectStacks
                                      .Where(s => s.ParentId == recipe.Id &&
                                             s.IsDeleted == 0 &&
                                             s.Type == ObjectStack.StackTypes.Ingredient)
                                      .AsEnumerable()
                                      .Select(s =>
            {
                s.Item = IngredientService.GetIngredientById(ctx, s.ItemId);
                return(s);
            })
                                      .ToList();
            recipeStack.Item = recipe;
            return(recipeStack);
        }