public void AgregarPuntaje(Antecedente antecedente, Victima victima) { if (antecedente == null) { throw new FaultException(Lenguaje.AntecedenteNoValido); } antecedente = RepositorioAntecedentes.DevolverPorId(antecedente.Id); if (antecedente == null) { throw new FaultException(Lenguaje.AntecedenteNoExiste); } if (victima == null) { throw new FaultException(Lenguaje.VictimaNoValida); } victima = RepositorioVictimas.DevolverPorId(victima.Id); if (victima == null) { throw new FaultException(Lenguaje.VictimaNoExiste); } RepositorioAntecedentes.InsertarPuntajes(antecedente, victima); }
public Victima DevolverVictimaPorId(int id) { var victima = RepositorioVictimas.DevolverPorId(id); if (victima == null) { throw new FaultException(Lenguaje.VictimaNoExiste); } return(victima); }
public int CrearAntecedente(Antecedente antecedente) { if (antecedente == null) { throw new FaultException(Lenguaje.AntecedenteNoValido); } if (String.IsNullOrWhiteSpace(antecedente.Nombre)) { throw new FaultException(Lenguaje.NombreNoValido); } if (String.IsNullOrWhiteSpace(antecedente.Perjuicios)) { throw new FaultException(Lenguaje.PerjuiciosNoValidos); } if (antecedente.Fecha > DateTime.Now) { throw new FaultException(Lenguaje.FechaNoValida); } if (String.IsNullOrWhiteSpace(antecedente.Ubicacion)) { throw new FaultException(Lenguaje.UbicacionNoValida); } if (antecedente.Estado == null) { throw new FaultException(Lenguaje.EstadoNoValido); } if (RepositorioEstados.DevolverPorId(antecedente.Estado.Id) == null) { throw new FaultException(Lenguaje.EstadoNoValido); } var victima = RepositorioVictimas.DevolverPorId(antecedente.Victima.Id); if (victima == null || victima.EstaBorrado == true) { throw new FaultException(Lenguaje.VictimaNoExiste); } var agresor = RepositorioAgresores.DevolverPorId(antecedente.Agresor.Id); if (agresor == null || agresor.EstaBorrado == true) { throw new FaultException(Lenguaje.AgresorNoExiste); } antecedente.Nombre.Trim(); antecedente.Observaciones.Trim(); antecedente.Perjuicios.Trim(); antecedente.Ubicacion.Trim(); RepositorioAntecedentes.Insertar(antecedente); return(antecedente.Id); }
public List <Antecedente> DevolverAntecedentesPorVictima(Victima victima, bool puntajes) { if (victima == null) { throw new FaultException(Lenguaje.VictimaNoValida); } victima = RepositorioVictimas.DevolverPorId(victima.Id); if (victima == null) { throw new FaultException(Lenguaje.VictimaNoExiste); } return(RepositorioAntecedentes.DevolverPorVictima(victima, puntajes)); }
public void EliminarVictima(Victima victima) { if (victima == null) { throw new FaultException(Lenguaje.VictimaNoValida); } victima = RepositorioVictimas.DevolverPorId(victima.Id); if (victima == null) { throw new FaultException(Lenguaje.VictimaNoExiste); } if (victima.EstaBorrado) { throw new FaultException(Lenguaje.VictimaYaEliminada); } victima.EstaBorrado = true; RepositorioVictimas.Modificar(victima); }
public void ModificarVictima(Victima victima) { if (victima == null) { throw new FaultException(Lenguaje.VictimaNoValida); } var victimaModificar = RepositorioVictimas.DevolverPorId(victima.Id); if (victimaModificar == null) { throw new FaultException(Lenguaje.VictimaNoExiste); } if (victimaModificar.EstaBorrado) { throw new FaultException(Lenguaje.VictimaYaEliminada); } if (string.IsNullOrWhiteSpace(victima.Nombre)) { throw new FaultException(Lenguaje.NombreNoValido); } if (string.IsNullOrWhiteSpace(victima.Apellido)) { throw new FaultException(Lenguaje.ApellidoNoValido); } if (String.IsNullOrWhiteSpace(victima.Apodo)) { throw new FaultException(Lenguaje.ApodoNoValido); } if (string.IsNullOrWhiteSpace(victima.Clave)) { throw new FaultException(Lenguaje.ClaveNoValida); } victimaModificar.Nombre = victima.Nombre.Trim(); victimaModificar.Apellido = victima.Apellido.Trim(); victimaModificar.Apodo = victima.Apodo.Trim(); victimaModificar.Clave = victima.Clave; RepositorioVictimas.Modificar(victimaModificar); }
public void ModificarAntecedente(Antecedente antecedente) { if (antecedente == null) { throw new FaultException(Lenguaje.AntecedenteNoValido); } var antecedenteModificar = RepositorioAntecedentes.DevolverPorId(antecedente.Id); if (antecedenteModificar == null) { throw new FaultException(Lenguaje.AntecedenteNoExiste); } if (String.IsNullOrWhiteSpace(antecedente.Nombre)) { throw new FaultException(Lenguaje.NombreNoValido); } if (String.IsNullOrWhiteSpace(antecedente.Perjuicios)) { throw new FaultException(Lenguaje.PerjuiciosNoValidos); } if (antecedente.Fecha == null) { throw new FaultException(Lenguaje.FechaNoValida); } if (String.IsNullOrWhiteSpace(antecedente.Ubicacion)) { throw new FaultException(Lenguaje.UbicacionNoValida); } if (antecedente.Estado == null) { throw new FaultException(Lenguaje.EstadoNoValido); } if (RepositorioEstados.DevolverPorId(antecedente.Estado.Id) == null) { throw new FaultException(Lenguaje.EstadoNoValido); } if (antecedente.Victima == null) { throw new FaultException(Lenguaje.VictimaNoValida); } var victima = RepositorioVictimas.DevolverPorId(antecedente.Victima.Id); if (victima == null || victima.EstaBorrado == true) { throw new FaultException(Lenguaje.VictimaNoExiste); } if (antecedente.Agresor == null) { throw new FaultException(Lenguaje.AgresorNoValido); } var agresor = RepositorioAgresores.DevolverPorId(antecedente.Agresor.Id); if (agresor == null || agresor.EstaBorrado == true) { throw new FaultException(Lenguaje.AgresorNoExiste); } antecedenteModificar.Estado = antecedente.Estado; antecedenteModificar.Nombre = antecedente.Nombre; antecedenteModificar.Victima = antecedente.Victima; antecedenteModificar.Agresor = antecedente.Agresor; antecedenteModificar.Fecha = antecedente.Fecha; antecedenteModificar.Observaciones = antecedente.Observaciones; antecedenteModificar.Perjuicios = antecedente.Perjuicios; antecedenteModificar.Ubicacion = antecedente.Ubicacion; antecedenteModificar.Latitud = antecedente.Latitud; antecedenteModificar.Longitud = antecedente.Longitud; RepositorioAntecedentes.Modificar(antecedenteModificar); }