Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Name,UnitID")] Ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ingredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UnitID"] = new SelectList(_context.UnitOfMeasurement, "ID", "ID", ingredient.UnitID);
            return(View(ingredient));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Name,Description,Instruction,Image")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                return(Redirect("~/Home/Index"));
            }

            return(View(recipe));
        }