示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Departamento departamento)
        {
            if (id != departamento.Id)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _departamentoService.UpdateAsync(departamento);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await _departamentoService.DepartamentoExists(departamento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(departamento));
        }