コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,CPF,Email,Cargo,TipoUsuarioId")] UserSecretaria userSecretaria)
        {
            if (id != userSecretaria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userSecretaria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserSecretariaExists(userSecretaria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TipoUsuarioId"] = new SelectList(_context.TipoUsuario, "Id", "Id", userSecretaria.TipoUsuarioId);
            return(View(userSecretaria));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Nome,CPF,Email,Cargo,TipoUsuarioId")] UserSecretaria userSecretaria)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userSecretaria);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TipoUsuarioId"] = new SelectList(_context.TipoUsuario, "Id", "Id", userSecretaria.TipoUsuarioId);
            return(View(userSecretaria));
        }