public ActionResult Create([Bind(Include = "CuisineID,CuisineName")] Cuisine cuisine)
        {
            if (ModelState.IsValid)
            {
                db.Cuisine.Add(cuisine);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cuisine));
        }
        public ActionResult Create([Bind(Include = "OccasionId,Name")] Occasion occasion)
        {
            if (ModelState.IsValid)
            {
                db.Occasions.Add(occasion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(occasion));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "DificultyId,Name")] Dificulty dificulty)
        {
            if (ModelState.IsValid)
            {
                db.Dificulties.Add(dificulty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dificulty));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "RecipeIngredientId,RecipeId,Ingredient")] RecipeIngredient recipeIngredient)
        {
            if (ModelState.IsValid)
            {
                db.RecipeIngredients.Add(recipeIngredient);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipeId = new SelectList(db.Recipes, "RecipeId", "Title", recipeIngredient.RecipeId);
            return(View(recipeIngredient));
        }
        public ActionResult Create([Bind(Include = "RecipeStepId,RecipeId,Description,Step")] RecipeStep recipeStep)
        {
            if (ModelState.IsValid)
            {
                db.RecipeSteps.Add(recipeStep);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipeId = new SelectList(db.Recipes, "RecipeId", "Title", recipeStep.RecipeId);
            return(View(recipeStep));
        }
        public IHttpActionResult AddRecipe([FromBody] Recipe recipe)
        {
            //Will Validate according to data annotations specified on model
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            return(Ok(recipe.RecipeID));
        }
        public ActionResult Create([Bind(Include = "RecipeCategoryId,RecipeId,CategoryId")] RecipeCategory recipeCategory)
        {
            if (ModelState.IsValid)
            {
                db.RecipeCategories.Add(recipeCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", recipeCategory.CategoryId);
            ViewBag.RecipeId   = new SelectList(db.Recipes, "RecipeId", "Title", recipeCategory.RecipeId);
            return(View(recipeCategory));
        }
Example #8
0
        public IHttpActionResult AddCusine([FromBody] Cuisine cuisine)
        {
            //Will Validate according to data annotations specified on model
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cuisine.Add(cuisine);
            db.SaveChanges();

            return(Ok(cuisine.CuisineID));
        }
        public ActionResult Create([Bind(Include = "RecipeOccasionId,RecipeId,OccasionId")] RecipeOccasion recipeOccasion)
        {
            if (ModelState.IsValid)
            {
                db.RecipeOccasions.Add(recipeOccasion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OccasionId = new SelectList(db.Occasions, "OccasionId", "Name", recipeOccasion.OccasionId);
            ViewBag.RecipeId   = new SelectList(db.Recipes, "RecipeId", "Title", recipeOccasion.RecipeId);
            return(View(recipeOccasion));
        }
Example #10
0
        public ActionResult Create(UserRatingViewModel userRating)
        {
            if (ModelState.IsValid)
            {
                var userRatingMap = MapViewToEntity(userRating);
                db.UserRatings.Add(userRatingMap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RecipeId = new SelectList(db.Recipes, "RecipeId", "Title", userRating.RecipeId);
            return(View(userRating));
        }
Example #11
0
 public virtual void Add(T item)
 {
     _context.Set <T>().Add(item);
     _context.SaveChanges();
 }