public static string WithRecipe(this TestCompositionRoot root,
                                        string name,
                                        string ingredients = null,
                                        string directions  = null,
                                        int?servings       = null,
                                        string source      = null,
                                        int?rating         = null,
                                        string category    = null,
                                        string id          = null)
        {
            var context = root.Get <RecipeBookDbContext>();

            var entity = new entityframework.Models.Recipe
            {
                Id          = id ?? Guid.NewGuid().ToString(),
                Name        = name,
                Ingredients = ingredients,
                Directions  = directions,
                Servings    = servings,
                Source      = source,
                Rating      = rating,
                Category    = category
            };

            context.Recipes.Add(entity);

            context.SaveChanges();

            return(entity.Id);
        }
Exemple #2
0
 private static void UpdateData(Recipe from, entityframework.Models.Recipe to)
 {
     to.Name        = from.Name;
     to.Servings    = from.Servings;
     to.Rating      = from.Rating;
     to.Ingredients = from.Ingredients;
     to.Directions  = from.Directions;
     to.Source      = from.Source;
     to.Category    = from.Category;
 }
Exemple #3
0
        private static Recipe Map(entityframework.Models.Recipe toMap)
        {
            if (toMap == null)
            {
                return(null);
            }

            return(new Recipe
            {
                Id = toMap.Id,
                Name = toMap.Name,
                Servings = toMap.Servings,
                Rating = toMap.Rating,
                Ingredients = toMap.Ingredients,
                Directions = toMap.Directions,
                Source = toMap.Source,
                Category = toMap.Category
            });
        }