Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public int CrearVictima(Victima victima)
 {
     if (victima == null)
     {
         throw new FaultException(Lenguaje.VictimaNoValida);
     }
     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);
     }
     victima.EstaBorrado = false;
     victima.Nombre.Trim();
     victima.Apellido.Trim();
     victima.Apodo.Trim();
     RepositorioVictimas.Insertar(victima);
     return(victima.Id);
 }
Exemplo n.º 3
0
        public Victima DevolverVictimaPorId(int id)
        {
            var victima = RepositorioVictimas.DevolverPorId(id);

            if (victima == null)
            {
                throw new FaultException(Lenguaje.VictimaNoExiste);
            }
            return(victima);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public List <Victima> DevolverVictimas()
 {
     return(RepositorioVictimas.DevolverTodos());
 }
Exemplo n.º 9
0
        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);
        }