예제 #1
0
        /// <summary>
        /// Devuelve la lista de Horarios de un lugar turistico especifico
        /// </summary>
        /// <param name="objeto">Lugar turistico</param>
        /// <returns></returns>
        public override List <Entidad> ConsultarLista(Entidad objeto)
        {
            List <Entidad> horarios = new List <Entidad>();

            try
            {
                StoredProcedure("consultarhorarios");
                Comando.Parameters.AddWithValue(NpgsqlDbType.Integer, objeto.Id);
                _respuesta = Comando.ExecuteReader();

                while (_respuesta.Read())
                {
                    Horario horario;
                    horario              = FabricaEntidad.CrearEntidadHorario();
                    horario.Id           = _respuesta.GetInt32(0);
                    horario.DiaSemana    = _respuesta.GetInt32(1);
                    horario.HoraApertura = _respuesta.GetTimeSpan(2);
                    horario.HoraCierre   = _respuesta.GetTimeSpan(3);

                    horarios.Add(horario);
                }

                return(horarios);
            }
            catch (NullReferenceException e)
            {
                log.Error(e.Message);
                throw new ReferenciaNulaExcepcion(e, "Parametros de entrada nulos en: "
                                                  + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
            }
            catch (InvalidCastException e)
            {
                log.Error("Casteo invalido en:"
                          + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
                throw new CasteoInvalidoExcepcion(e, "Ocurrio un casteo invalido en: "
                                                  + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
            }
            catch (NpgsqlException e)
            {
                log.Error("Ocurrio un error en la base de datos en: "
                          + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
                throw new BaseDeDatosExcepcion(e, "Ocurrio un error en la base de datos en: "
                                               + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
            }
            catch (SocketException e)
            {
                log.Error("Ocurrio un error en la base de datos en: "
                          + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
                throw new SocketExcepcion(e, "Ocurrio un error en la base de datos en: "
                                          + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
            }
            catch (Exception e)
            {
                log.Error("Ocurrio un error desconocido: "
                          + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
                throw new Excepcion(e, "Ocurrio un error desconocido en: "
                                    + GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + ". " + e.Message);
            }
            finally
            {
                Desconectar();
            }
        }