public static void ModificarFuente(Fuente fuente) { int resultado = 0; if (fuente is Periodista) { ValidarPeriodista(fuente); resultado = PersistenciaPeriodista.ModificarPeriodista((Periodista)fuente); if (resultado == -1) { throw new ExcepcionLogica("No se encontró un periodista con ese identificador."); } } else if (fuente is Agencia) { ValidarAgencia(fuente); resultado = PersistenciaAgencia.ModificarAgencia((Agencia)fuente); if (resultado == -1) { throw new ExcepcionLogica("No se encontró una Agencia con ese identificador."); } } else { throw new ExcepcionLogica("Tipo de Fuente no reconocido."); } }
public static void AltaFuente(Fuente fuente) { int resultado = 0; if (fuente is Periodista) { ValidarPeriodista(fuente); resultado = PersistenciaPeriodista.AltaPeriodista((Periodista)fuente); } else if (fuente is Agencia) { ValidarAgencia(fuente); resultado = PersistenciaAgencia.AltaAgencia((Agencia)fuente); } else { throw new ExcepcionLogica("Fuente no reconocida."); } if (resultado == -1) { throw new ExcepcionLogica("El identificador ya se encuentra en uso."); } else if (resultado == -3) { throw new ExcepcionLogica("El documento " + ((Periodista)fuente).DocumentoIdentidad + " ya existe en la base de datos."); } }
public static Fuente BuscarFuente(int id) { Fuente f = PersistenciaPeriodista.BuscarPeriodista(id); if (f == null) { f = PersistenciaAgencia.BuscarAgencia(id); } return(f); }
public static Agencia BuscarAgencia(int id) { Agencia a = PersistenciaAgencia.BuscarAgencia(id); if (a == null) { throw new ExcepcionLogica("No se encontró la Agencia."); } return(a); }
public static void BajaAgencia(int id) { int resultado = PersistenciaAgencia.BajaAgencia(id); if (resultado == -1) { throw new ExcepcionLogica("No se encontró una Agencia con ese identificador."); } else if (resultado == -3) { throw new ExcepcionLogica("La Agencia tiene artículos en la base de datos, no se puede eliminar."); } }