// GET: Adoptante/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { ViewData["Error"] = await ErrorAsync("Adoptante", "Edit", "No se ingreso el Id", 400); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var result = await GetAsync("api/Adoptante/" + id.Value); Adoptante adoptante = null; if (result.IsSuccessStatusCode) { var resultdata = result.Content.ReadAsStringAsync().Result; adoptante = JsonConvert.DeserializeObject <Adoptante>(resultdata); } if (adoptante == null) { ViewData["Error"] = await ErrorAsync("Adoptante", "Edit", "Error al consultar api", 404); return(HttpNotFound()); } await SetDomicilio(adoptante.Domicilio.ProvinciaId, adoptante.Domicilio.CantonId); return(View(adoptante)); }
public async Task <IActionResult> Edit(int id, [Bind("AdoptanteId,Nombre,Apellido1,Apellido2,Telefono,Email,Calle,Colonia,Ciudad,Estado,FechaN")] Adoptante adoptante) { if (id != adoptante.AdoptanteId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adoptante); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdoptanteExists(adoptante.AdoptanteId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(adoptante)); }
public List <Adoptante> ConsultarAdoptantes() { IDbConnection _conn = DASoftColitas.Conexion(); _conn.Open(); SqlCommand _Comand = new SqlCommand("SP_CONSULTAR_ADOPTANTES", _conn as SqlConnection); _Comand.CommandType = CommandType.StoredProcedure; IDataReader _reader = _Comand.ExecuteReader(); List <Adoptante> _list = new List <Adoptante>(); while (_reader.Read()) { Adoptante adoptante = new Adoptante(); adoptante.IDAdoptante = _reader.GetInt32(0); adoptante.Cedula = _reader.GetString(1); adoptante.NombreCompleto = _reader.GetString(2); adoptante.Telefono = _reader.GetString(3); adoptante.Correo = _reader.GetString(4); adoptante.Direccion = _reader.GetString(5); adoptante.CodigoAnimal = _reader.GetString(6); adoptante.EstadoCalificacion = _reader.GetString(7); adoptante.IDUsuario = _reader.GetInt32(8); _list.Add(adoptante); } _conn.Close(); return(_list); }
public Adoptante BuscarAdoptante(string _adop) { Adoptante adoptante = new Adoptante(); IDbConnection _conn = DASoftColitas.Conexion(); _conn.Open(); SqlCommand _Comand = new SqlCommand("SP_BUSCAR_ADOPTANTE", _conn as SqlConnection); _Comand.CommandType = CommandType.StoredProcedure; _Comand.Parameters.Add(new SqlParameter("@USERNAME", _adop)); IDataReader _reader = _Comand.ExecuteReader(); while (_reader.Read()) { adoptante.IDAdoptante = _reader.GetInt32(0); adoptante.Cedula = _reader.GetString(1); adoptante.NombreCompleto = _reader.GetString(2); adoptante.Telefono = _reader.GetString(3); adoptante.Correo = _reader.GetString(4); adoptante.Direccion = _reader.GetString(5); adoptante.CodigoAnimal = _reader.GetString(6); adoptante.EstadoCalificacion = _reader.GetString(7); adoptante.IDUsuario = _reader.GetInt32(8); } _conn.Close(); return(adoptante); }
public async Task <IActionResult> Create([Bind("AdoptanteId,Nombre,Apellido1,Apellido2,Telefono,Email,Calle,Colonia,Ciudad,Estado,FechaN")] Adoptante adoptante) { if (ModelState.IsValid) { _context.Add(adoptante); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(adoptante)); }
// Intermediario para el create de Adoptantes public async Task <IActionResult> IntermediarioCreate(String emailUsuario) { Console.WriteLine("Entré al intermediario"); Adoptante obj = new Adoptante(); obj.Email = emailUsuario; obj.FechaN = DateTime.Now; await Create(obj); return(RedirectToAction(nameof(Index))); }
public bool Update(Adoptante entity) { try { DB.ActualizarAdoptante(entity.Identificacion, entity.Nombre, entity.Primer_Apellido, entity.Segundo_Apellido, entity.Fecha_Nacimiento, entity.Telefono, entity.Correo, entity.DomicilioId); return(true); } catch (Exception ex) { throw ex; } }
public int Insert(Adoptante entity) { try { var id = DB.InsertarAdoptante(entity.Identificacion, entity.Nombre, entity.Primer_Apellido, entity.Segundo_Apellido, entity.Fecha_Nacimiento, entity.Telefono, entity.Correo, entity.DomicilioId).SingleOrDefault().Column1; return(id.Value); } catch (Exception ex) { throw ex; } }
// PUT: api/Adoptante/5 public IHttpActionResult Put(string id, [FromBody] Adoptante adoptante) { try { adoptante.Id = Convert.ToInt32(id); AdoptanteServicio.Update(adoptante); return(Ok()); } catch (Exception ex) { Log.Error <AdoptanteController>("Put Se ha producido un error en el llamado de la URI= " + Url.Request.RequestUri, ex); return(BadRequest()); } }
// POST: api/Adoptante public IHttpActionResult Post([FromBody] Adoptante adoptante) { try { adoptante.Id = AdoptanteServicio.Insert(adoptante); Uri uri = new Uri(Url.Request.RequestUri + "/" + adoptante.Id); return(Created(uri, ModelFactory.Create <AdoptanteModel, Adoptante>(adoptante, uri))); } catch (Exception ex) { Log.Error <AdoptanteController>("Post Se ha producido un error en el llamado de la URI= " + Url.Request.RequestUri, ex); return(BadRequest()); } }
public int EliminarAdoptante(Adoptante adoptante) { IDbConnection _conn = DASoftColitas.Conexion(); _conn.Open(); SqlCommand _Comand = new SqlCommand("SP_ELIMINAR_ADOPTANTE", _conn as SqlConnection); _Comand.CommandType = CommandType.StoredProcedure; _Comand.Parameters.Add(new SqlParameter("@CEDULA", adoptante.Cedula)); int Resultado = _Comand.ExecuteNonQuery(); _conn.Close(); return(Resultado); }
public int ModificarAdoptante(Adoptante adoptante) { IDbConnection _conn = DASoftColitas.Conexion(); _conn.Open(); SqlCommand _Comand = new SqlCommand("SP_MODIFICAR_ADOPTANTE", _conn as SqlConnection); _Comand.CommandType = CommandType.StoredProcedure; _Comand.Parameters.Add(new SqlParameter("@TELEFONO", adoptante.Telefono)); _Comand.Parameters.Add(new SqlParameter("@DIRECCION", adoptante.Direccion)); _Comand.Parameters.Add(new SqlParameter("@CORREO", adoptante.Correo)); _Comand.Parameters.Add(new SqlParameter("@ESTADO", adoptante.EstadoCalificacion)); int Resultado = _Comand.ExecuteNonQuery(); _conn.Close(); return(Resultado); }
private async Task <bool> RegistarAdoptante(Adoptante adoptante) { if (await ValidarAdoptante(adoptante.Identificacion)) { var resultDomicilio = await PostAsync("api/Domicilio", adoptante.Domicilio); if (resultDomicilio.IsSuccessStatusCode) { string resultdata = resultDomicilio.Content.ReadAsStringAsync().Result; adoptante.Domicilio = JsonConvert.DeserializeObject <Domicilio>(resultdata); var result = await PostAsync("api/Adoptante", adoptante); return(result.IsSuccessStatusCode); } return(false); } return(true); }
private void btnBuscarAdoptante_Click(object sender, EventArgs e) { try { if (txtCedula.Text.Trim() == "") { errorProvider.SetError(txtCedula, "Debe ingresar un número de cédula"); } else { Adoptante _adop = _dla.BuscarAdoptante(txtCedula.Text); if (_adop.IDAdoptante != 0) { txtNombre.Text = _adop.NombreCompleto; txtTelefono.Text = _adop.Telefono; txtCorreo.Text = _adop.Correo; txtDomicilio.Text = _adop.Direccion; if (_adop.EstadoCalificacion == "Califica") { rbCalifica.Checked = true; } else { rbNoCalifica.Checked = true; } cboxAnimales.Text = _adop.CodigoAnimal; txtCedula.Enabled = false; txtNombre.Enabled = false; cboxAnimales.Enabled = false; btnModificar.Enabled = true; } else { MessageBox.Show("La cédula ingresada no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch { MessageBox.Show("No hay registros", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int AgregarAdoptante(Adoptante adoptante) { IDbConnection _conn = DASoftColitas.Conexion(); _conn.Open(); SqlCommand _Comand = new SqlCommand("SP_AGREGAR_ADOPTANTE", _conn as SqlConnection); _Comand.CommandType = CommandType.StoredProcedure; _Comand.Parameters.Add(new SqlParameter("@CEDULA", adoptante.Cedula)); _Comand.Parameters.Add(new SqlParameter("@NOMBRE_COMPLETO", adoptante.NombreCompleto)); _Comand.Parameters.Add(new SqlParameter("@TELEFONO", adoptante.Telefono)); _Comand.Parameters.Add(new SqlParameter("@CORREO", adoptante.Correo)); _Comand.Parameters.Add(new SqlParameter("@DIRECCION", adoptante.Direccion)); _Comand.Parameters.Add(new SqlParameter("@CODIGO_ANIMAL", adoptante.CodigoAnimal)); _Comand.Parameters.Add(new SqlParameter("@ESTADO", adoptante.EstadoCalificacion)); _Comand.Parameters.Add(new SqlParameter("@IDUSUARIO", adoptante.IDUsuario)); int Resultado = _Comand.ExecuteNonQuery(); _conn.Close(); return(Resultado); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Identificacion,Nombre,Primer_Apellido,Segundo_Apellido,Fecha_Nacimiento,Telefono,Correo,DomicilioId,Domicilio")] Adoptante adoptante) { if (ModelState.IsValid) { var resultDomicilio = await PutAsync("api/Domicilio/" + adoptante.DomicilioId, adoptante.Domicilio); if (resultDomicilio.IsSuccessStatusCode) { var result = await PutAsync("api/Adoptante/" + adoptante.Id, adoptante); if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } } } await SetDomicilio(adoptante.Domicilio.ProvinciaId, adoptante.Domicilio.CantonId); ViewData["Error"] = await ErrorAsync("Adoptante", "Edit", "Error actualizar adoptante compruebe los campos", 400); return(View(adoptante)); }
public int EliminarAdoptante(Adoptante adoptante) { return(_daa.EliminarAdoptante(adoptante)); }
public int ModificarAdoptante(Adoptante adoptante) { return(_daa.ModificarAdoptante(adoptante)); }
public int AgregarAdoptante(Adoptante adoptante) { return(_daa.AgregarAdoptante(adoptante)); }