コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Glass glass)
        {
            if (id != glass.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(glass);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GlassExists(glass.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(glass));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IngredientId,Amount,CoctailId")] Compounds compounds)
        {
            if (id != compounds.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(compounds);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompoundsExists(compounds.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CoctailId"]    = new SelectList(_context.Coctails, "Id", "Name", compounds.CoctailId);
            ViewData["IngredientId"] = new SelectList(_context.Ingredients, "Id", "Name", compounds.IngredientId);
            return(View(compounds));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,YearofCreation,CountryofCreationId,CreationHistory,StrengthId,TechniqueId,GlassId,Recipe")] Coctails coctails)
        {
            if (id != coctails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(coctails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoctailsExists(coctails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryofCreationId"] = new SelectList(_context.Country, "Id", "Name", coctails.CountryofCreationId);
            ViewData["GlassId"]             = new SelectList(_context.Glass, "Id", "Name", coctails.GlassId);
            ViewData["StrengthId"]          = new SelectList(_context.Strengths, "Id", "Name", coctails.StrengthId);
            ViewData["TechniqueId"]         = new SelectList(_context.Techniques, "Id", "Name", coctails.TechniqueId);
            return(View(coctails));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CategoryId,Description")] Ingredients ingredients)
        {
            if (id != ingredients.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ingredients);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IngredientsExists(ingredients.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", ingredients.CategoryId);
            return(View(ingredients));
        }