예제 #1
0
        public IActionResult Edit(int id, [Bind("Id,Name,Comment,Price,Available")] Beer beer)
        {
            if (id != beer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repo.Update(beer);
                    _repo.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_repo.Exists(beer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(beer));
        }