// GET: Cita/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var cita = await _context.Cita.FindAsync(id); if (cita == null) { return(NotFound()); } var mc = new MascotaController(); List <string> n = mc.obtenerNombres(); SelectList list = new SelectList(n); ViewData["MascotaID"] = list; var veterinarioQuery = from v in _context.Veterinario orderby v.Nombre select v; ViewData["VeterinarioID"] = new SelectList(veterinarioQuery.AsNoTracking(), "Id", "Nombre"); var MedicamentoQuery = from me in _context.Medicamento orderby me.Nombre select me; ViewData["MedicamentoID"] = new SelectList(MedicamentoQuery, "Id", "Nombre"); return(View(cita)); }
// GET: Cita/Create public IActionResult Create() { var mc = new MascotaController(); List <string> n = mc.obtenerNombres(); SelectList list = new SelectList(n); ViewData["MascotaID"] = list; var veterinarioQuery = from v in _context.Veterinario orderby v.Nombre select v; ViewData["VeterinarioID"] = new SelectList(veterinarioQuery.AsNoTracking(), "Id", "Nombre"); var MedicamentoQuery = from me in _context.Medicamento orderby me.Nombre select me; ViewData["MedicamentoID"] = new SelectList(MedicamentoQuery, "Id", "Nombre"); return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Fecha,Descripcion,MascotaID,VeterinarioID,MedicamentoID")] Cita cita) { if (id != cita.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cita); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CitaExists(cita.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var mc = new MascotaController(); List <string> n = mc.obtenerNombres(); SelectList list = new SelectList(n); ViewData["MascotaID"] = list; var veterinarioQuery = from v in _context.Veterinario orderby v.Nombre select v; ViewData["VeterinarioID"] = new SelectList(veterinarioQuery.AsNoTracking(), "Id", "Nombre"); var MedicamentoQuery = from me in _context.Medicamento orderby me.Nombre select me; ViewData["MedicamentoID"] = new SelectList(MedicamentoQuery, "Id", "Nombre"); return(View(cita)); }
public async Task <IActionResult> Create([Bind("Id,Fecha,Descripcion,MascotaID,VeterinarioID,MedicamentoID")] Cita cita) { if (ModelState.IsValid) { _context.Add(cita); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var mc = new MascotaController(); List <string> n = mc.obtenerNombres(); SelectList list = new SelectList(n); ViewData["MascotaID"] = list; var veterinarioQuery = from v in _context.Veterinario orderby v.Nombre select v; ViewData["VeterinarioID"] = new SelectList(veterinarioQuery.AsNoTracking(), "Id", "Nombre"); var MedicamentoQuery = from me in _context.Medicamento orderby me.Nombre select me; ViewData["MedicamentoID"] = new SelectList(MedicamentoQuery, "Id", "Nombre"); return(View(cita)); }