Exemple #1
0
        public Agresor DevolverAgresorPorId(int id, bool telefonos, bool direcciones, bool redesSociales)
        {
            var agresor = RepositorioAgresores.DevolverPorId(id, telefonos, direcciones, redesSociales);

            if (agresor == null)
            {
                throw new FaultException(Lenguaje.AgresorNoExiste);
            }
            return(agresor);
        }
        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> 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));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public List <Agresor> DevolverAgresores(bool telefonos, bool direcciones, bool redesSociales)
 {
     return(RepositorioAgresores.DevolverTodos(telefonos, direcciones, redesSociales));
 }
Exemple #6
0
        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 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);
        }