コード例 #1
0
        // 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));
        }
コード例 #2
0
        // 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());
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }