Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Category category)
        {
            if (id != category.Id)
            {
                return(View("Error"));
            }

            if (!ModelState.IsValid)
            {
                return(View("Error"));
            }
            else
            {
                try
                {
                    await _repository.ConfirmEdit(category);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
        }