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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cargoSecretaria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CargoSecretariaExists(cargoSecretaria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cargoSecretaria));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Descricao")] CargoSecretaria cargoSecretaria)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cargoSecretaria);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cargoSecretaria));
        }