示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Name, Calories, Origin")] Seasoning seasoning, [Bind("Id,Hotness")] Herbs herbs)
        {
            if (id != herbs.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    seasoning.Id = id;
                    _context.Seasoning.Update(seasoning);
                    _context.Update(herbs);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HerbsExists(herbs.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", herbs.Id);
            return(View(herbs));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Fiber")] Ingredient ingredient, [Bind("Id,Fiber")] Vegetable vegetable)
        {
            if (id != vegetable.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ingredient.Id = id;
                    _context.Ingredient.Update(ingredient);
                    _context.Update(vegetable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VegetableExists(vegetable.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Ingredient, "Id", "Id", vegetable.Id);
            return(View(vegetable));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,R_id,I_id,Weight")] MyRecipe_Ingredient myRecipe_Ingredient)
        {
            if (id != myRecipe_Ingredient.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(myRecipe_Ingredient);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MyRecipe_IngredientExists(myRecipe_Ingredient.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["I_id"] = new SelectList(_context.Ingredient, "Id", "Id", myRecipe_Ingredient.I_id);
            ViewData["R_id"] = new SelectList(_context.MyRecipe, "Id", "Id", myRecipe_Ingredient.R_id);
            return(View(myRecipe_Ingredient));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Calories")] Ingredient ingredient, [Bind("Id,Protein")] Meat meat)
        {
            if (id != meat.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ingredient.Id = id;
                    _context.Ingredient.Update(ingredient);
                    _context.Update(meat);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MeatExists(meat.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Ingredient, "Id", "Id", meat.Id);
            return(View(meat));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] MyRecipe myRecipe)
        {
            if (id != myRecipe.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(myRecipe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MyRecipeExists(myRecipe.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(myRecipe));
        }