Esempio n. 1
0
 private async Task SetCategories(RecipeDto recipe)
 {
     using (var dc = RecipeContext.ContextFactory())
     {
         recipe.Categories = await dc.Categories
                             .Where(c => c.Recipes.Any(r => r.RecipeId == recipe.Id))
                             .Select(c => c.Description)
                             .ToListAsync();
     }
 }
Esempio n. 2
0
 private async Task SetDirections(RecipeDto recipe)
 {
     using (var dc = RecipeContext.ContextFactory())
     {
         recipe.Directions = await dc.Directions
                             .Where(d => d.Recipe.RecipeId == recipe.Id)
                             .OrderBy(d => d.LineNumber)
                             .Select(d => d.Description)
                             .ToListAsync();
     }
 }
Esempio n. 3
0
 private async Task SetIngredients(RecipeDto recipe)
 {
     using (var dc = RecipeContext.ContextFactory())
     {
         recipe.Ingredients = await
                                  (from r in dc.Recipes
                                  where r.RecipeId == recipe.Id
                                  from i in r.Ingredients
                                  orderby i.SortOrder
                                  select new IngredientDto {
             Decription = i.Description, Amount = i.Units, AmountType = i.UnitType
         })
                              .ToListAsync();
     }
 }