Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,BreweryId,Abv,StyleId,Notes")] BeerViewModel beer)
        {
            if (id != beer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(beer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_common.BeerExists(beer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            beer.BreweryList = _common.GetBreweryChoices();
            beer.StyleList   = _common.GetStyleChoices();
            return(View(beer));
        }