public ActionResult EliminarPV(string id) { int _id = Convert.ToInt32(id); Agresor agresor = servicioWeb.DevolverAgresorPorId(_id, false, false, false); return(PartialView("EliminarPV", agresor)); }
public int Agresores_Insertar(Agresor agresor) { var parametros = CrearParametros(agresor, false); return(Convert.ToInt32(DevolverEscalar("Agresores_Insertar", parametros))); //if (agresor.Foto == null) //{ // return Convert.ToInt32(DevolverEscalar("Agresores_Insertar", // new SqlParameter("@Nombre", agresor.Nombre), // new SqlParameter("@Apellido", agresor.Apellido), // new SqlParameter("@Apodo", agresor.Apodo), // new SqlParameter("@Ocupacion", agresor.Ocupacion), // new SqlParameter("@Caracteristicas", agresor.Caracteristicas), // new SqlParameter("@Metodos", agresor.Metodos), // new SqlParameter("@EstaBorrado", agresor.EstaBorrado))); //} //else //{ // return Convert.ToInt32(DevolverEscalar("Agresores_Insertar", // new SqlParameter("@Nombre", agresor.Nombre), // new SqlParameter("@Apellido", agresor.Apellido), // new SqlParameter("@Apodo", agresor.Apodo), // new SqlParameter("@Ocupacion", agresor.Ocupacion), // new SqlParameter("@Caracteristicas", agresor.Caracteristicas), // new SqlParameter("@Metodos", agresor.Metodos), // new SqlParameter("@Foto", agresor.Foto), // new SqlParameter("@EstaBorrado", agresor.EstaBorrado))); //} }
public int AgresoresRedesSociales_Insertar(RedSocial redSocial, Agresor agresor) { return(Convert.ToInt32(DevolverEscalar("AgresoresRedesSociales_Insertar", new SqlParameter("@IdAgresor", agresor.Id), new SqlParameter("@IdTipoRedSocial", redSocial.Tipo.Id), new SqlParameter("@Nombre", redSocial.Nombre)))); }
public void Agresores_Modificar(Agresor agresor) { var parametros = CrearParametros(agresor, true); EjecutarConsulta("Agresores_Modificar", parametros); //if (agresor.Foto == null) //{ // EjecutarConsulta("Agresores_Modificar", // new SqlParameter("@IdAgresor", agresor.Id), // new SqlParameter("@Nombre", agresor.Nombre), // new SqlParameter("@Apellido", agresor.Apellido), // new SqlParameter("@Apodo", agresor.Apodo), // new SqlParameter("@Ocupacion", agresor.Ocupacion), // new SqlParameter("@Caracteristicas", agresor.Caracteristicas), // new SqlParameter("@Metodos", agresor.Metodos), // new SqlParameter("@EstaBorrado", agresor.EstaBorrado)); //} //else //{ // EjecutarConsulta("Agresores_Modificar", // new SqlParameter("@IdAgresor", agresor.Id), // new SqlParameter("@Nombre", agresor.Nombre), // new SqlParameter("@Apellido", agresor.Apellido), // new SqlParameter("@Apodo", agresor.Apodo), // new SqlParameter("@Ocupacion", agresor.Ocupacion), // new SqlParameter("@Caracteristicas", agresor.Caracteristicas), // new SqlParameter("@Metodos", agresor.Metodos), // new SqlParameter("@Foto", agresor.Foto), // new SqlParameter("@EstaBorrado", agresor.EstaBorrado)); //} }
public int AgresoresTelefonos_Insertar(Telefono telefono, Agresor agresor) { return(Convert.ToInt32(DevolverEscalar("AgresoresTelefonos_Insertar", new SqlParameter("@IdAgresor", agresor.Id), new SqlParameter("@IdTipoTelefono", telefono.Tipo.Id), new SqlParameter("@IdLocalidad", telefono.Localidad.Id), new SqlParameter("@Numero", telefono.Numero)))); }
/*INSERTAR POR AGRESOR*/ public int AgresoresDirecciones_Insertar(Direccion direccion, Agresor agresor) { return(Convert.ToInt32(DevolverEscalar("AgresoresDirecciones_Insertar", new SqlParameter("@IdAgresor", agresor.Id), new SqlParameter("@IdLocalidad", direccion.Localidad.Id), new SqlParameter("@IdTipoDireccion", direccion.Tipo.Id), new SqlParameter("@Calle", direccion.Calle), new SqlParameter("@Numero", direccion.Numero), new SqlParameter("@Departamento", direccion.Departamento), new SqlParameter("@Piso", direccion.Piso)))); }
public List <Antecedente> DevolverAntecedentesPorAgresor(Agresor agresor, bool puntajes) { if (agresor == null) { throw new FaultException(Lenguaje.AgresorNoValido); } agresor = RepositorioAgresores.DevolverPorId(agresor.Id); if (agresor == null) { throw new FaultException(Lenguaje.AgresorNoExiste); } return(RepositorioAntecedentes.DevolverPorAgresor(agresor, puntajes)); }
public List <Antecedente> DevolverPorAgresor(Agresor agresor, bool puntajes) { using (var dt = accesoDatos.Antecedentes_DevolverPorAgresor(agresor)) { entidades = TablaALista(dt); if (puntajes) { foreach (var item in entidades) { item.Puntajes = DevolverPuntajesPorAntecedente(item); } } } return(entidades); }
public void EliminarAgresor(Agresor agresor) { if (agresor == null) { throw new FaultException(Lenguaje.AgresorNoValido); } agresor = RepositorioAgresores.DevolverPorId(agresor.Id); if (agresor == null) { throw new FaultException(Lenguaje.AgresorNoExiste); } if (agresor.EstaBorrado) { throw new FaultException(Lenguaje.AgresorYaEliminado); } agresor.EstaBorrado = true; RepositorioAgresores.Modificar(agresor); }
protected void lnkAceptar_Click(object sender, EventArgs e) { try { var agresor = new Agresor(); agresor.Nombre = txtNombre.Text; agresor.Apellido = txtApellido.Text; agresor.Apodo = txtApodo.Text; agresor.Ocupacion = txtOcupacion.Text; agresor.Caracteristicas = txtCaracteristicas.Text; agresor.Metodos = txtMetodos.Text; agresor.Foto = null; servicioWeb.CrearAgresor(agresor); Response.Redirect("Agresores.aspx"); } catch (Exception ex) { lblMensaje.Visible = true; lblMensaje.Text = ex.Message; } }
protected void btnAceptarNuevaDireccion_Click(object sender, EventArgs e) { int id = Convert.ToInt32(hdnIdAgresor.Value); Agresor agresor = servicioWeb.DevolverAgresorPorId(id, true, true, true); Direccion direccion = new Direccion(); direccion.Localidad = new Localidad(); direccion.Localidad = servicioWeb.DevolverLocalidadPorId (Convert.ToInt32(ddlLocalidadDireccion.SelectedValue)); direccion.Tipo = new TipoDireccion(); direccion.Tipo.Id = Convert.ToByte(ddlTipoDireccion.SelectedValue); direccion.Tipo.Nombre = ddlTipoDireccion.SelectedItem.Text; direccion.Calle = txtCalle.Text; direccion.Numero = txtNumeroDireccion.Text; if (ddlTipoDireccion.SelectedValue == "2") { direccion.Piso = txtPiso.Text; direccion.Departamento = txtDepartamento.Text; } else { direccion.Piso = string.Empty; direccion.Departamento = string.Empty; } //var pepe = agresor.Direcciones.ToList(); //pepe.Add(direccion); //agresor.Direcciones = pepe.ToArray(); var listaDirecciones = agresor.Direcciones.ToList(); listaDirecciones.Add(direccion); agresor.Direcciones = listaDirecciones.ToArray(); servicioWeb.ModificarAgresor(agresor); //System.Threading.Thread.Sleep(3000); grdDirecciones.DataSource = (servicioWeb.DevolverAgresorPorId(id, false, true, false)).Direcciones; grdDirecciones.DataBind(); }
protected void btnAceptarNuevaRedSocial_Click(object sender, EventArgs e) { int id = Convert.ToInt32(hdnIdAgresor.Value); Agresor agresor = servicioWeb.DevolverAgresorPorId(id, true, true, true); RedSocial redSocial = new RedSocial(); redSocial.Tipo = new TipoRedSocial(); redSocial.Tipo.Id = Convert.ToByte(ddlTipoRedSocial.SelectedValue); redSocial.Tipo.Nombre = ddlTipoRedSocial.SelectedItem.Text; redSocial.Nombre = txtNombreRedSocial.Text; var listaRedesSociales = agresor.RedesSociales.ToList(); listaRedesSociales.Add(redSocial); agresor.RedesSociales = listaRedesSociales.ToArray(); servicioWeb.ModificarAgresor(agresor); grdRedesSociales.DataSource = (servicioWeb.DevolverAgresorPorId(id, false, false, true)).RedesSociales; grdRedesSociales.DataBind(); }
private SqlParameter[] CrearParametros(Agresor agresor, bool incluirId) { var parametros = new List <SqlParameter>(); if (incluirId) { parametros.Add(new SqlParameter("@IdAgresor", agresor.Id)); } parametros.Add(new SqlParameter("@Nombre", agresor.Nombre)); parametros.Add(new SqlParameter("@Apellido", agresor.Apellido)); parametros.Add(new SqlParameter("@Apodo", agresor.Apodo)); parametros.Add(new SqlParameter("@Ocupacion", agresor.Ocupacion)); parametros.Add(new SqlParameter("@Caracteristicas", agresor.Caracteristicas)); parametros.Add(new SqlParameter("@Metodos", agresor.Metodos)); parametros.Add(new SqlParameter("@EstaBorrado", agresor.EstaBorrado)); if (agresor.Foto != null) { parametros.Add(new SqlParameter("@Foto", agresor.Foto)); } return(parametros.ToArray()); }
protected void lnkAplicarCambios_Click(object sender, EventArgs e) { try { //CREA AGRESOR var agresor = new Agresor(); agresor.Id = Convert.ToInt32(hdnIdAgresor.Value); agresor.Nombre = txtNombre.Text; agresor.Apellido = txtApellido.Text; agresor.Apodo = txtApodo.Text; agresor.Ocupacion = txtOcupacion.Text; agresor.Caracteristicas = txtCaracteristicas.Text; agresor.Metodos = txtMetodos.Text; //CREA DIRECCIONES DE AGRESOR var direcciones = new List <Direccion>(); var vectorDirecciones = hdnDirecciones.Value.Split(','); var contadorDirecciones = 0; for (int i = 0; i < vectorDirecciones.Length / 6; i++) { var direccion = new Direccion(); direccion.Tipo = new TipoDireccion() { Id = Convert.ToByte(vectorDirecciones[contadorDirecciones]) }; contadorDirecciones++; direccion.Localidad = new Localidad() { Id = Convert.ToInt32(vectorDirecciones[contadorDirecciones]) }; contadorDirecciones++; direccion.Calle = vectorDirecciones[contadorDirecciones]; contadorDirecciones++; direccion.Numero = vectorDirecciones[contadorDirecciones]; contadorDirecciones++; direccion.Piso = vectorDirecciones[contadorDirecciones]; contadorDirecciones++; direccion.Departamento = vectorDirecciones[contadorDirecciones]; contadorDirecciones++; direcciones.Add(direccion); } agresor.Direcciones = direcciones.ToArray(); //CREA REDES SOCIALES DE AGRESOR var redesSociales = new List <RedSocial>(); var vectorRedesSociales = hdnRedesSociales.Value.Split(','); var contadorRedesSociales = 0; for (int i = 0; i < vectorRedesSociales.Length / 2; i++) { var redSocial = new RedSocial(); redSocial.Tipo = new TipoRedSocial() { Id = Convert.ToByte(vectorRedesSociales[contadorRedesSociales]) }; contadorRedesSociales++; redSocial.Nombre = vectorRedesSociales[contadorRedesSociales]; contadorRedesSociales++; redesSociales.Add(redSocial); } agresor.RedesSociales = redesSociales.ToArray(); //CREA TELEFONOS DE AGRESOR var telefonos = new List <Telefono>(); var vectorTelefonos = hdnTelefonos.Value.Split(','); var contador = 0; for (int i = 0; i < vectorTelefonos.Length / 3; i++) { var telefono = new Telefono(); telefono.Tipo = new TipoTelefono() { Id = Convert.ToByte(vectorTelefonos[contador]) }; contador++; telefono.Localidad = new Localidad() { Id = Convert.ToInt32(vectorTelefonos[contador]) }; contador++; telefono.Numero = vectorTelefonos[contador]; contador++; telefonos.Add(telefono); } agresor.Telefonos = telefonos.ToArray(); servicioWeb.ModificarAgresor(agresor); Response.Redirect(QueryStrings_Url(urlAgresoresDetalle, "id=" + hdnIdAgresor.Value)); } catch (Exception ex) { litMensaje.Visible = true; litMensaje.Text = ex.Message; } }
public DataTable Antecedentes_DevolverPorAgresor(Agresor agresor) { return(DevolverTabla("Antecedentes_DevolverPorAgresor", new SqlParameter("@IdAgresor", agresor.Id))); }
public void Crear(Agresor agresor) { agresor.EstaBorrado = false; servicioWeb.CrearAgresor(agresor); }
public void Eliminar(Agresor agresor) { servicioWeb.EliminarAgresor(agresor); }
public void AgresoresTelefonos_EliminarPorAgresor(Agresor agresor) { EjecutarConsulta("AgresoresTelefonos_EliminarPorAgresor", new SqlParameter("@IdAgresor", agresor.Id)); }
public void AgresoresRedesSociales_EliminarPorAgresor(Agresor agresor) { EjecutarConsulta("AgresoresRedesSociales_EliminarPorAgresor", new SqlParameter("@IdAgresor", agresor.Id)); }
public DataTable AgresoresDirecciones_DevolverPorAgresor(Agresor agresor) { return(DevolverTabla("AgresoresDirecciones_DevolverPorAgresor", new SqlParameter("@IdAgresor", agresor.Id))); }
public DataTable AgresoresRedesSociales_DevolverPorAgresor(Agresor agresor) { return(DevolverTabla("AgresoresRedesSociales_DevolverPorAgresor", new SqlParameter("@IdAgresor", agresor.Id))); }
public void ModificarAgresor(Agresor agresor) { if (agresor == null) { throw new FaultException(Lenguaje.AgresorNoExiste); } var agresorModificar = RepositorioAgresores.DevolverPorId(agresor.Id); if (agresorModificar == null) { throw new FaultException(Lenguaje.AgresorNoExiste); } if (agresorModificar.EstaBorrado) { throw new FaultException(Lenguaje.AgresorYaEliminado); } if (string.IsNullOrWhiteSpace(agresor.Nombre) & string.IsNullOrWhiteSpace(agresor.Apellido) & string.IsNullOrWhiteSpace(agresor.Apodo)) { throw new FaultException(Lenguaje.AgresorSinNombreApellidoApodo); } if (string.IsNullOrEmpty(agresor.Nombre)) { agresor.Nombre = string.Empty; } if (string.IsNullOrEmpty(agresor.Apellido)) { agresor.Apellido = string.Empty; } if (string.IsNullOrEmpty(agresor.Apodo)) { agresor.Apodo = string.Empty; } if (string.IsNullOrWhiteSpace(agresor.Ocupacion)) { throw new FaultException(Lenguaje.OcupacionNoValida); } if (string.IsNullOrWhiteSpace(agresor.Metodos)) { throw new FaultException(Lenguaje.MetodosNoValidos); } if (string.IsNullOrWhiteSpace(agresor.Caracteristicas)) { throw new FaultException(Lenguaje.CaracteristicasNoValidas); } agresorModificar.Nombre = agresor.Nombre.Trim(); agresorModificar.Apellido = agresor.Apellido.Trim(); agresorModificar.Apodo = agresor.Apodo.Trim(); agresorModificar.Ocupacion = agresor.Ocupacion.Trim(); agresorModificar.Metodos = agresor.Metodos.Trim(); agresorModificar.Direcciones = agresor.Direcciones; agresorModificar.RedesSociales = agresor.RedesSociales; agresorModificar.Telefonos = agresor.Telefonos; agresorModificar.Caracteristicas = agresor.Caracteristicas.Trim(); if (agresor.Telefonos != null) { foreach (var item in agresor.Telefonos) { item.Localidad = RepositorioLocalidades.DevolverPorId(item.Localidad.Id); if (item.Localidad == null) { throw new FaultException(Lenguaje.LocalidadNoValida); } item.Tipo = RepositorioTiposTelefonos.DevolverPorId(item.Tipo.Id); if (item.Tipo == null) { throw new FaultException(Lenguaje.TipoTelefonoNoValido); } if (string.IsNullOrWhiteSpace(item.Numero)) { throw new FaultException(Lenguaje.NumeroNoValido); } } } if (agresor.Direcciones != null) { foreach (var item in agresor.Direcciones) { item.Localidad = RepositorioLocalidades.DevolverPorId(item.Localidad.Id); if (item.Localidad == null) { throw new FaultException(Lenguaje.LocalidadNoValida); } item.Tipo = RepositorioTiposDirecciones.DevolverPorId(item.Tipo.Id); if (item.Tipo == null) { throw new FaultException(Lenguaje.TipoDireccionNoValido); } if (string.IsNullOrWhiteSpace(item.Calle)) { throw new FaultException(Lenguaje.CalleNoValida); } if (string.IsNullOrWhiteSpace(item.Numero)) { throw new FaultException(Lenguaje.NumeroNoValido); } switch ((EnumTiposDirecciones)item.Tipo.Id) { case EnumTiposDirecciones.Departamento: if (string.IsNullOrWhiteSpace(item.Departamento) | item.Departamento.Length > 4) { throw new FaultException(Lenguaje.DepartamentoNoValido); } if (string.IsNullOrWhiteSpace(item.Piso) | item.Piso.Length > 3) { throw new FaultException(Lenguaje.PisoNoValido); } break; default: item.Departamento = string.Empty; item.Piso = string.Empty; break; } } } if (agresor.RedesSociales != null) { foreach (var item in agresor.RedesSociales) { item.Tipo = RepositorioTiposRedesSociales.DevolverPorId(item.Tipo.Id); if (item.Tipo == null) { throw new FaultException(Lenguaje.TipoRedSocialNoValido); } if (string.IsNullOrEmpty(item.Nombre)) { throw new FaultException(Lenguaje.NombreNoValido); } } } RepositorioAgresores.Modificar(agresorModificar); RepositorioAgresores.EliminarTelefonoPorAgresor(agresorModificar); if (agresorModificar.Telefonos != null) { foreach (var item in agresorModificar.Telefonos) { RepositorioAgresores.InsertarTelefono(item, agresorModificar); } } RepositorioAgresores.EliminarDireccionPorAgresor(agresorModificar); if (agresorModificar.Direcciones != null) { foreach (var item in agresorModificar.Direcciones) { RepositorioAgresores.InsertarDireccion(item, agresorModificar); } } RepositorioAgresores.EliminarRedSocialPorAgresor(agresorModificar); if (agresorModificar.RedesSociales != null) { foreach (var item in agresorModificar.RedesSociales) { RepositorioAgresores.InsertarRedSocial(item, agresorModificar); } } }
public void Modificar(Agresor agresor, string[][] arrayDirecciones, string[][] arrayRedesSociales, string[][] arrayTelefonos) { if (ModelState.IsValid) { } //DIRECCIONES ARRAY A OBJETO List <Direccion> listaDirecciones = new List <Direccion>(); if (arrayDirecciones != null) { foreach (var item in arrayDirecciones) { var direccion = new Direccion(); direccion.Tipo = new TipoDireccion() { Id = Convert.ToByte(item[0]) }; direccion.Localidad = new Localidad() { Id = Convert.ToInt32(item[1]) }; direccion.Calle = item[2]; direccion.Numero = item[3]; direccion.Piso = item[4]; direccion.Departamento = item[5]; listaDirecciones.Add(direccion); } } //REDES SOCIALES ARRAY A OBJETO List <RedSocial> listaRedesSociales = new List <RedSocial>(); if (arrayRedesSociales != null) { foreach (var item in arrayRedesSociales) { var redSocial = new RedSocial(); redSocial.Tipo = new TipoRedSocial() { Id = Convert.ToByte(item[0]) }; redSocial.Nombre = item[1]; listaRedesSociales.Add(redSocial); } } //TELEFONOS ARRAY A OBJETO List <Telefono> listaTelefonos = new List <Telefono>(); if (arrayTelefonos != null) { foreach (var item in arrayTelefonos) { var telefono = new Telefono(); telefono.Tipo = new TipoTelefono() { Id = Convert.ToByte(item[0]) }; telefono.Localidad = new Localidad() { Id = Convert.ToInt32(item[1]) }; telefono.Numero = item[2]; listaTelefonos.Add(telefono); } } //AGREGO LISTAS A AGRESOR (transformo a array) agresor.Direcciones = listaDirecciones.ToArray(); agresor.RedesSociales = listaRedesSociales.ToArray(); agresor.Telefonos = listaTelefonos.ToArray(); //CHECK AGRESOR agresor.EstaBorrado = false; if (agresor.Nombre == null) { agresor.Nombre = ""; } if (agresor.Apellido == null) { agresor.Apellido = ""; } if (agresor.Apodo == null) { agresor.Apodo = ""; } //SERVICIOWEB A BASE DE DATOS servicioWeb.ModificarAgresor(agresor); }