Ejemplo n.º 1
0
 protected void ButRegistrar_Click(object sender, EventArgs e)
 {
     try {
         Mascota mascota = new Mascota();
         mascota.Nombre  = TextNombre.Text;
         mascota.Raza    = TextRaza.Text;
         mascota.Sexo    = TextSexo.Text;
         mascota.Usuario = new Usuario()
         {
             Id = Convert.ToInt32(userId)
         };
         mascotaBL.RegistrarMascota(mascota);
         //Page.Response.Redirect("Main.aspx");
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Mascota Registrada')", true);
         Page.Response.Redirect("Main.aspx?ID=" + userId);
     } catch (Exception) {
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Error. Inténtelo Nuevamente.')", true);
     }
 }
        public ActionResult Guardar(MascotaEL mascotaEL)
        {
            var resultado = mascotaEL.MascotaId > 0 ? mascotaBL.ActualizarMascota(mascotaEL) : mascotaBL.RegistrarMascota(mascotaEL);

            if (resultado <= 0)
            {
                ViewBag.Mensaje = "Ocurrió un error";
                return(View("~/Views/Shared/_Mensaje.cshtml"));
            }
            return(Redirect("~/mascota/index"));
        }