Exemple #1
0
 public int AddRecipe(RecipeDetailsModel receptModell)
 {
     ////Utan databas
     //Recipes.Add(receptModell);
     //return Recipes.Count-1;
     using (var db = new RecipesEntities())
     {
         var toAdd = new Recipes
         {
             Name         = receptModell.Name,
             Summary      = receptModell.Summary,
             CookingTime  = receptModell.CookingTimeInMinutes,
             Ingredients  = receptModell.Ingredients,
             Instructions = receptModell.Instructions
         };
         db.Recipes.Add(toAdd);
         db.SaveChanges();
         return(toAdd.ID);
     }
 }
Exemple #2
0
        public int AddRecipe(RecipeDetailsModel receptModell)
        {
            ////Utan databas
            //Recipes.Add(receptModell);
            //return Recipes.Count-1;
            using (var db = new RecipesEntities())
            {
                var toAdd = new Recipes
                {
                    Name = receptModell.Name,
                    Summary = receptModell.Summary,
                    CookingTime = receptModell.CookingTimeInMinutes,
                    Ingredients=receptModell.Ingredients,
                    Instructions = receptModell.Instructions

                };
                db.Recipes.Add(toAdd);
                db.SaveChanges();
                return toAdd.ID;
            }
        }