コード例 #1
0
        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.");
            }
        }
コード例 #2
0
        public static List <Fuente> ListarFuentes()
        {
            List <Fuente> fuentes = Persistencia.PersistenciaAgencia.ListarAgencias();

            fuentes.AddRange(PersistenciaPeriodista.ListarPeriodistas());
            return(fuentes);
        }
コード例 #3
0
        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.");
            }
        }
コード例 #4
0
        public static Periodista BuscarPeriodista(int id)
        {
            Periodista p = PersistenciaPeriodista.BuscarPeriodista(id);

            if (p == null)
            {
                throw new ExcepcionLogica("No se encontró el periodista.");
            }
            return(p);
        }
コード例 #5
0
        public static Fuente BuscarFuente(int id)
        {
            Fuente f = PersistenciaPeriodista.BuscarPeriodista(id);

            if (f == null)
            {
                f = PersistenciaAgencia.BuscarAgencia(id);
            }
            return(f);
        }
コード例 #6
0
        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.");
            }
        }