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 List <Fuente> ListarFuentes() { List <Fuente> fuentes = Persistencia.PersistenciaAgencia.ListarAgencias(); fuentes.AddRange(PersistenciaPeriodista.ListarPeriodistas()); return(fuentes); }
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 Periodista BuscarPeriodista(int id) { Periodista p = PersistenciaPeriodista.BuscarPeriodista(id); if (p == null) { throw new ExcepcionLogica("No se encontró el periodista."); } return(p); }
public static Fuente BuscarFuente(int id) { Fuente f = PersistenciaPeriodista.BuscarPeriodista(id); if (f == null) { f = PersistenciaAgencia.BuscarAgencia(id); } return(f); }
public static void BajaPeriodista(int id) { int resultado = PersistenciaPeriodista.BajaPeriodista(id); if (resultado == -1) { throw new ExcepcionLogica("No se encontró un periodista con ese identificador."); } else if (resultado == -3) { throw new ExcepcionLogica("El periodista tiene artículos en la base de datos, no se puede eliminar."); } }