public ActionResult EditInfante(Infante obj) { try { if (ModelState.IsValid) { InfanteRepository InfanRepo = new InfanteRepository(); if (InfanRepo.UpdateInfante(obj)) { ViewBag.Message = "Infante modificado"; } else { ViewBag.Message = "Ocurrio un error"; } return(RedirectToAction("GetInfantes")); } return(View(obj)); } catch { return(RedirectToAction("GetInfantes")); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Infante = await _context.Infante .Include(i => i.Tutor).FirstOrDefaultAsync(m => m.InfanteId == id); if (Infante == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Infante = await _context.Infante .Include(i => i.Tutor).FirstOrDefaultAsync(m => m.InfanteId == id); if (Infante == null) { return(NotFound()); } ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "Apellido"); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Infante = await _context.Infante.FindAsync(id); if (Infante != null) { _context.Infante.Remove(Infante); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public ActionResult EditInfante(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InfanteRepository InfanRepo = new InfanteRepository(); Infante result = InfanRepo.ListarInfantes() .Find(Inf => Inf.Infante_ID == id); if (result == null) { return(HttpNotFound()); } return(View(result)); }
public bool UpdateInfante(Infante obj) { connection(); SqlCommand com = new SqlCommand("ModificarInfante", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@inf_id", obj.Infante_ID); com.Parameters.AddWithValue("@inf_nhc", obj.Infante_Historial); com.Parameters.AddWithValue("@inf_nom", obj.Infante_Nombre); com.Parameters.AddWithValue("@inf_ape", obj.Infante_Apellido); com.Parameters.AddWithValue("@inf_fecnac", obj.Infante_FecNac); com.Parameters.AddWithValue("@inf_sex", obj.Infante_Sexo); com.Parameters.AddWithValue("@inf_lugar", obj.Infante_Lugar); com.Parameters.AddWithValue("@inf_exgen_id", obj.Infante_Exa_Gen); com.Parameters.AddWithValue("@inf_exfis_id", obj.Infante_Exa_Fis); con.Open(); int i = com.ExecuteNonQuery(); con.Close(); bool result = i >= 1 ? true : false; return(result); }
public ActionResult AddInfante(Infante inf) { try { if (ModelState.IsValid) { InfanteRepository InfanRepo = new InfanteRepository(); if (InfanRepo.AddInfante(inf)) { ViewBag.Message = "Infante agregado"; } else { ViewBag.Message = "Ocurrio un error"; } } return(RedirectToAction("GetInfantes")); } catch { return(View()); } }
public ActionResult Editar(int id) { List <Infante> infantes = new List <Infante>(); infantes.Add(new Infante { Infante_ID = 1, Infante_Nombre = "Jorge", Infante_Apellido = "Gonzáles", Infante_Lugar = "Arequipa", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 1, Infante_Examen_Fis = 1 }); infantes.Add(new Infante { Infante_ID = 2, Infante_Nombre = "Freddy", Infante_Apellido = "Mercury", Infante_Lugar = "Lima", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 1, Infante_Examen_Fis = 1 }); infantes.Add(new Infante { Infante_ID = 3, Infante_Nombre = "Enrique", Infante_Apellido = "Bumbury", Infante_Lugar = "Huancayo", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 1, Infante_Examen_Fis = 2 }); infantes.Add(new Infante { Infante_ID = 4, Infante_Nombre = "Jhonn", Infante_Apellido = "Lennon", Infante_Lugar = "Iquitos", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 3, Infante_Examen_Fis = 1 }); infantes.Add(new Infante { Infante_ID = 5, Infante_Nombre = "Bob", Infante_Apellido = "Marley", Infante_Lugar = "El callao", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 3, Infante_Examen_Fis = 5 }); infantes.Add(new Infante { Infante_ID = 6, Infante_Nombre = "Albert", Infante_Apellido = "Einstein", Infante_Lugar = "Pucallpa", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 2, Infante_Examen_Fis = 4 }); infantes.Add(new Infante { Infante_ID = 7, Infante_Nombre = "Nicola", Infante_Apellido = "Tesla", Infante_Lugar = "San Juan de Lurigancho", Infante_Hora = DateTime.Now, Infante_Sexo = "M", Infante_Examen_Gen = 1, Infante_Examen_Fis = 1 }); Infante persona = (from p in infantes where p.Infante_ID == id select p).FirstOrDefault(); return(View(persona)); }