Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("RegistroAdopcionId,MascotaId,AdoptanteId,FechaAdop,EnumProceso")] RegistroAdopcion registroAdopcion)
        {
            if (id != registroAdopcion.RegistroAdopcionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(registroAdopcion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegistroAdopcionExists(registroAdopcion.RegistroAdopcionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdoptanteId"] = new SelectList(_context.Adoptante, "AdoptanteId", "AdoptanteId", registroAdopcion.AdoptanteId);
            ViewData["MascotaId"]   = new SelectList(_context.Mascotas, "MascotaId", "MascotaId", registroAdopcion.MascotaId);
            return(View(registroAdopcion));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("RegistroAdopcionId,MascotaId,AdoptanteId,FechaAdop,EnumProceso")] RegistroAdopcion registroAdopcion)
        {
            Console.WriteLine("Este es el post: " + registroAdopcion.MascotaId +
                              " " + registroAdopcion.AdoptanteId + " " + registroAdopcion.FechaAdop);
            if (ModelState.IsValid)
            {
                _context.Add(registroAdopcion);
                await _context.SaveChangesAsync();

                return(RedirectToAction("SolicitudEnviada", "Mascotas"));
            }
            ViewData["AdoptanteId"] = new SelectList(_context.Adoptante, "AdoptanteId", "AdoptanteId", registroAdopcion.AdoptanteId);
            ViewData["MascotaId"]   = new SelectList(_context.Mascotas, "MascotaId", "MascotaId", registroAdopcion.MascotaId);
            return(View(registroAdopcion));
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                RegistroAdopcion adopcion = new RegistroAdopcion("", "", "", "", "");

                adopcion.Cedula           = TextBox1.Text;
                adopcion.NombreAdoptante  = TextBox2.Text;
                adopcion.Direccion        = TextBox3.Text;
                adopcion.Telefono         = TextBox4.Text;
                adopcion.Mascota_adoptada = TextBox5.Text;
                adopcion.agregar();
                Label6.Text   = "Registro Agregado";
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";
                TextBox5.Text = "";
            }
            catch
            {
                Label6.Text = "Mascota no existe";
            }
        }