public ActionResult Register([Bind(Include = "UserID,Name,UserName,Password,Email")] UserInfo userInfo)
        {
            if (ModelState.IsValid)
            {
                db.UserInfoes.Add(userInfo);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            return(View(userInfo));
        }
        public ActionResult Create([Bind(Include = "Id,IngredientName")] Ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                db.Ingredients.Add(ingredient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ingredient));
        }
        public ActionResult Create([Bind(Include = "ID,Title,Year,Rated,Genre,Metascore,imdbRating,BoxOffice")] MovieFavorite movieFavorite)
        {
            if (ModelState.IsValid)
            {
                db.MovieFavorites.Add(movieFavorite);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movieFavorite));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "Id,Name,PrepTime,CookTime,NumberServ,Steps,RecipeType")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                db.Recipes.Add(recipe);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(recipe));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,RecipeId,IngredientId,Amount,AmountSize")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                db.RecipeIngredients.Add(recipeIngredient);
                db.SaveChanges();
                return(RedirectToAction("Index", "Recipe"));
            }

            ViewBag.IngredientId = new SelectList(db.Ingredients, "Id", "IngredientName", recipeIngredient.IngredientId);
            ViewBag.RecipeId     = new SelectList(db.Recipes, "Id", "Name", recipeIngredient.RecipeId);
            return(View(recipeIngredient));
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            using (RecipeEntities db = new RecipeEntities())
            {
                Recipe recipe = new Recipe()
                {
                    Name = "Chicken"
                };

                db.Recipes.Add(recipe);
                db.SaveChanges();


                //Recipe r = db.Recipes.FirstOrDefault(x => x.Name == "Burger");
                //Console.WriteLine(r.Id);

                //Console.WriteLine("Done");
                //r.Name = "Burger";
                //db.SaveChanges();
                //db.Recipes.Remove(r);
                //db.SaveChanges();
                Console.WriteLine("Done");
                Console.ReadKey();
            }
        }