コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nacionalidad,GeneroId,FechaNacimiento,DireccionResidencia,Telefono1,Telefono2,PoseeCarro,PoseeLicencia,MunicipioId")] DatosCandidato datosCandidato)
        {
            if (id != datosCandidato.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(datosCandidato);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DatosCandidatoExists(datosCandidato.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GeneroId"] = new SelectList(_context.Set <Genero>(), "Id", "Id", datosCandidato.GeneroId);
            return(View(datosCandidato));
        }
コード例 #2
0
        public async Task <IActionResult> Create(DatosCandidato datosCandidato)
        {
            if (ModelState.IsValid)
            {
                _context.Add(datosCandidato);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Dashboard"));
            }

            ViewData["Paises"]  = new SelectList(_context.Paises, "Id", "Nombre");
            ViewData["Generos"] = new SelectList(_context.Generos, "Id", "Nombre");
            return(View(datosCandidato));
        }