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 SiniestrosController(RepositorioSiniestros repositorioSiniestros, RepositorioEstados repositorioEstados, RepositorioAseguradoras repositorioAseguradoras, RepositorioUsuarios repositorioUsuarios, RepositorioPeritos repositorioPeritos, RepositorioDanios repositorioDanios, RepositorioPermisos repositorioPermisos) { _repositorioSiniestros = repositorioSiniestros; _repositorioEstados = repositorioEstados; _repositorioAseguradoras = repositorioAseguradoras; _repositorioUsuarios = repositorioUsuarios; _repositorioPeritos = repositorioPeritos; _repositorioDanios = repositorioDanios; _repositorioPermisos = repositorioPermisos; }
public ServicioEstado() { try { conexion = new ConexionBD(); repositorio = new RepositorioEstados(conexion.AbrirConexion()); } catch (Exception e) { throw new Exception(e.Message); } }
public void Borrar(Estado estado) { try { conexion = new ConexionBD(); repositorio = new RepositorioEstados(conexion.AbrirConexion()); repositorio.Borrar(estado); conexion.CerrarConexion(); } catch (Exception e) { throw new Exception(e.Message); } }
public bool EstaRelacionado(Estado estado) { try { conexion = new ConexionBD(); repositorio = new RepositorioEstados(conexion.AbrirConexion()); var relacionado = repositorio.EstaRelacionado(estado); conexion.CerrarConexion(); return(relacionado); } catch (Exception e) { throw new Exception(e.Message); } }
public bool Existe(Estado estado) { try { conexion = new ConexionBD(); repositorio = new RepositorioEstados(conexion.AbrirConexion()); var existe = repositorio.Existe(estado); conexion.CerrarConexion(); return(existe); } catch (Exception e) { throw new Exception(e.Message); } }
public List <Estado> GetLista() { try { conexion = new ConexionBD(); repositorio = new RepositorioEstados(conexion.AbrirConexion()); var lista = repositorio.GetLista(); conexion.CerrarConexion(); return(lista); } catch (Exception e) { throw new Exception(e.Message); } }
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); }
public List <Estado> DevolverEstados() { return(RepositorioEstados.DevolverTodos()); }