コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Idempleado,Cargoempleado,Usuarioempleado,Contrasenaempleado,Fcreacion,Fultimoacceso,Numdocumento,Idroles,Idestadou")] Templeado templeado)
        {
            if (id != templeado.Idempleado)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(templeado);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TempleadoExists(templeado.Idempleado))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Idestadou"]    = new SelectList(_context.Estadousuarioemp, "Idestadou", "Idestadou", templeado.Idestadou);
            ViewData["Idroles"]      = new SelectList(_context.Troles, "Idroles", "Idroles", templeado.Idroles);
            ViewData["Numdocumento"] = new SelectList(_context.Tusuario, "Numdocumento", "Numdocumento", templeado.Numdocumento);
            return(View(templeado));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Idempleado,Cargoempleado,Usuarioempleado,Contrasenaempleado,Fcreacion,Fultimoacceso,Numdocumento,Idroles,Idestadou")] Templeado templeado)
        {
            if (ModelState.IsValid)
            {
                _context.Add(templeado);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Idestadou"]    = new SelectList(_context.Estadousuarioemp, "Idestadou", "Idestadou", templeado.Idestadou);
            ViewData["Idroles"]      = new SelectList(_context.Troles, "Idroles", "Idroles", templeado.Idroles);
            ViewData["Numdocumento"] = new SelectList(_context.Tusuario, "Numdocumento", "Numdocumento", templeado.Numdocumento);
            return(View(templeado));
        }