Beispiel #1
0
        public void DAOInsertarLugarTuristico()
        {
            LugarTuristico resultado = FabricaEntidad.CrearEntidadLugarTuristico();

            iDAOLugarTuristico = FabricaDAO.CrearDAOLugarTuristico();

            iDAOLugarTuristico.Insertar(_lugaresTuristicos[0]);
            _lugaresTuristicos = iDAOLugarTuristico.ConsultarTodaLaLista();

            //Obtengo el ultimo lugar insertado
            foreach (LugarTuristico lugar in _lugaresTuristicos)
            {
                resultado = lugar;
            }

            Assert.AreEqual(2, resultado.Id);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Nombre, resultado.Nombre);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Costo, resultado.Costo);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Descripcion, resultado.Descripcion);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Direccion, resultado.Direccion);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Correo, resultado.Correo);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Telefono, resultado.Telefono);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Latitud, resultado.Latitud);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Longitud, resultado.Longitud);
            Assert.AreEqual(((LugarTuristico)_lugaresTuristicos[0]).Activar, resultado.Activar);
        }
        public void SetLugarTuristico()
        {
            lugar = new LugarTuristico();

            lugar.Id          = 1;
            lugar.Nombre      = "Parque del Este";
            lugar.Costo       = 0;
            lugar.Descripcion = "Lugar al aire libre";
            lugar.Direccion   = "Frente a la estacion Parque del Este, Caracas";
            lugar.Correo      = "*****@*****.**";
            lugar.Telefono    = 02122732867;
            lugar.Latitud     = 20.0;
            lugar.Longitud    = 10.0;
            lugar.Activar     = true;

            lugar.Foto.Add(new Foto());
            lugar.Horario.Add(new Horario());
            lugar.Actividad.Add(new Actividad());

            pruebaLugar = new LugarTuristico();

            pruebaLugar.Id          = 1;
            pruebaLugar.Nombre      = "Parque del Este";
            pruebaLugar.Costo       = 0;
            pruebaLugar.Descripcion = "Lugar al aire libre";
            pruebaLugar.Direccion   = "Frente a la estacion Parque del Este, Caracas";
            pruebaLugar.Correo      = "*****@*****.**";
            pruebaLugar.Telefono    = 02122732867;
            pruebaLugar.Latitud     = 20.0;
            pruebaLugar.Longitud    = 10.0;
            pruebaLugar.Activar     = true;
        }
Beispiel #3
0
 public ActionResult Create(LugarTuristico lugar)
 {
     com = FabricaComando.GetComandoAgregarLugarTuristico();
     LlenadoLugarTuristico();
     com.Execute();
     return(RedirectToAction("ViewAll"));
 }
Beispiel #4
0
 public ActionResult Modify(LugarTuristico lugar)
 {
     com = FabricaComando.GetComandoModificarLugarTuristico();
     LlenadoLugarTuristico();
     com.SetPropiedad(Request.Form["Id"]);
     com.Execute();
     return(RedirectToAction("ViewAll"));
 }
Beispiel #5
0
        public void TestExcepcionInsertarLugarTuristico()
        {
            lugar.Nombre = null;
            Assert.Catch <CasteoInvalidoExcepcion>(ExcepcionInsertarLugarTuristico);

            lugar = null;
            Assert.Catch <ReferenciaNulaExcepcion>(ExcepcionInsertarLugarTuristico);
        }
Beispiel #6
0
 /// <summary>
 /// Actualiza la informacion de un lugar turistico
 /// </summary>
 /// <param name="lugar">Entidad lugar turistico</param>
 /// <returns></returns>
 public override void Actualizar(Entidad lugar)
 {
     _lugarTuristico = (LugarTuristico)lugar;
     try
     {
         StoredProcedure("ActualizarLugarTuristico");
         Comando.Parameters.AddWithValue(NpgsqlDbType.Integer, _lugarTuristico.Id);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Varchar, _lugarTuristico.Nombre);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Numeric, _lugarTuristico.Costo);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Varchar, _lugarTuristico.Descripcion);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Varchar, _lugarTuristico.Direccion);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Varchar, _lugarTuristico.Correo);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Bigint, _lugarTuristico.Telefono);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Numeric, _lugarTuristico.Latitud);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Numeric, _lugarTuristico.Longitud);
         Comando.Parameters.AddWithValue(NpgsqlDbType.Boolean, _lugarTuristico.Activar);
         // Ejecucion
         Comando.ExecuteNonQuery();
     }
     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();
     }
 }
Beispiel #7
0
        /// <summary>
        /// Inserta toda la data asociada a un lugar turistico en la base de datos.
        /// </summary>
        /// <param name="lugarTuristico">Objeto lugar turistico con todos los campos obligatorios llenos</param>
        /// <returns>(int) ID del Lugar Turistico</returns>
        /// <exception cref="BaseDeDatosExcepcion"></exception>
        /// <exception cref="CasteoInvalidoExcepcion"></exception>
        /// <exception cref="ReferenciaNulaExcepcion"></exception>
        /// <exception cref="ArchivoExcepcion"></exception>
        public int InsertarLugarTuristico(LugarTuristico lugarTuristico)
        {
            try
            {
                conexion.Conectar();

                lugarTuristico.Id = conexion.InsertarLugarTuristico(lugarTuristico);

                foreach (Horario elemento in lugarTuristico.Horario)
                {
                    conexion.InsertarHorario(elemento, lugarTuristico.Id);
                }

                foreach (Foto elemento in lugarTuristico.Foto)
                {
                    conexion.InsertarFoto(elemento, lugarTuristico.Id);
                }

                foreach (Actividad elemento in lugarTuristico.Actividad)
                {
                    conexion.InsertarActividad(elemento, lugarTuristico.Id);
                }

                foreach (Categoria elemento in lugarTuristico.Categoria)
                {
                    conexion.InsertarCategoriaLugarTuristico(lugarTuristico.Id, elemento.Id);
                }

                foreach (Categoria elemento in lugarTuristico.SubCategoria)
                {
                    conexion.InsertarCategoriaLugarTuristico(lugarTuristico.Id, elemento.Id);
                }

                conexion.Desconectar();

                return(lugarTuristico.Id);
            }
            catch (BaseDeDatosExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (CasteoInvalidoExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (ReferenciaNulaExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (ArchivoExcepcion e)
            {
                throw e;
            }
        }
Beispiel #8
0
 public ActionResult Guardar(LugarTuristico lugar)
 {
     if (!ModelState.IsValid)
     {
         return(View("FormGuardar", lugar));
     }
     servicio.AddLugarTuristico(lugar);
     return(RedirectToAction("Index"));
 }
Beispiel #9
0
        public void FalloEliminarLugar_It()
        {
            itinerario = new Itinerario(6);
            LugarTuristico lt = new LugarTuristico()
            {
                Id = 1
            };

            x = controller.EliminarItem_It("LugarTuristico", itinerario.Id, lt.Id);
            Assert.False(x);
        }
Beispiel #10
0
        public void PU_ConsultarLugares()
        {
            string busqueda = "Parque Generalisimo de Miranda";

            comando = FabricaComando.CrearComandoListarCoincidenciaLugaresTurisiticos(busqueda);
            comando.Ejecutar();
            lista = comando.RetornarLista();
            LugarTuristico lugarTuristico = (LugarTuristico)lista[0];

            Assert.AreEqual(busqueda, lugarTuristico.Nombre);
            Assert.AreEqual(2, lugarTuristico.Id);
        }
Beispiel #11
0
        public void TestConsultarListaLugarTuristico()
        {
            lugar             = new LugarTuristico();
            lugar.Id          = idLugar;
            lugar.Nombre      = "Parque Generalisimo de Miranda";
            lugar.Costo       = 0;
            lugar.Descripcion = "Lugar al aire libre";
            lugar.Activar     = true;

            conexion.Conectar();
            Assert.AreEqual(true, conexion.ConsultarListaLugarTuristico(1, lugar.Id).Contains(lugar));
            conexion.Desconectar();
        }
Beispiel #12
0
        public void FalloAgregarLugar_It()
        {
            itinerario = new Itinerario(6);
            LugarTuristico lt = new LugarTuristico()
            {
                Id = 1
            };

            fechaini = new DateTime(2017, 11, 15);
            fechafin = new DateTime(2017, 11, 18);
            x        = controller.AgregarItem_It("LugarTuristico", itinerario.Id, lt.Id, fechaini, fechafin);
            Assert.False(x);
        }
Beispiel #13
0
        public List <LugarTuristico> ConsultarLugaresTuristicos(string busqueda)
        {
            comando = FabricaComando.CrearComandoListarCoincidenciaLugaresTurisiticos(busqueda);
            comando.Ejecutar();
            List <LugarTuristico> listaLugar = new List <LugarTuristico>();

            foreach (Entidad item in comando.RetornarLista())
            {
                LugarTuristico lugarNew = (LugarTuristico)item;
                listaLugar.Add(lugarNew);
            }
            return(listaLugar);
        }
Beispiel #14
0
        /// <summary>
        /// Actualiza toda la data asociada a un lugar turistico en la base de datos.
        /// </summary>
        /// <param name="lugarTuristico">Objeto lugar turistico con todos los campos obligatorios llenos
        /// y, el ID de cada lugar turistico, horario, foto y actividad si aplica</param>
        /// <exception cref="BaseDeDatosExcepcion"></exception>
        /// <exception cref="CasteoInvalidoExcepcion"></exception>
        /// <exception cref="ReferenciaNulaExcepcion"></exception>
        /// <exception cref="ArchivoExcepcion"></exception>
        public void ActualizarLugarTuristico(LugarTuristico lugarTuristico)
        {
            try
            {
                conexion.Conectar();

                conexion.ActualizarLugarTuristico(lugarTuristico);

                foreach (Horario elemento in lugarTuristico.Horario)
                {
                    conexion.ActualizarHorario(elemento);
                }

                foreach (Foto elemento in lugarTuristico.Foto)
                {
                    conexion.ActualizarFoto(elemento);
                }

                if (lugarTuristico.Actividad != null)
                {
                    foreach (Actividad elemento in lugarTuristico.Actividad)
                    {
                        conexion.ActualizarActividad(elemento);
                    }
                }

                //Categorias y
                // sub-categorias de las categorias

                conexion.Desconectar();
            }
            catch (BaseDeDatosExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (CasteoInvalidoExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (ReferenciaNulaExcepcion e)
            {
                e.NombreMetodos.Add(this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name);
                throw e;
            }
            catch (ArchivoExcepcion e)
            {
                throw e;
            }
        }
Beispiel #15
0
        public void ActualizarLugar(LugarTuristico lugar)
        {
            LugarTuristico lugarDB = context.LugarTuristicos
                                     .Find(lugar.IdLugarTuristico);

            lugarDB.Nombre       = lugar.Nombre;
            lugarDB.PrecioNino   = lugar.PrecioNino;
            lugarDB.PrecioAdulto = lugar.PrecioAdulto;
            lugarDB.Ubicacion    = lugar.Ubicacion;
            lugarDB.Descripcion  = lugar.Descripcion;
            lugarDB.Imagen       = lugar.Imagen;

            context.SaveChanges();
        }
Beispiel #16
0
        public ActionResult Actualizar(LugarTuristico lugar)
        {
            //var lugarDB = context.LugarTuristicos
            //    .Find(lugar.IdLugarTuristico);
            //lugarDB.Nombre = lugar.Nombre;
            //lugarDB.PrecioNino = lugar.PrecioNino;
            //lugarDB.PrecioAdulto = lugar.PrecioAdulto;
            //lugarDB.Ubicacion = lugar.Ubicacion;
            //lugarDB.Descripcion = lugar.Descripcion;
            //lugarDB.Imagen = lugar.Imagen;

            //context.SaveChanges();
            servicio.ActualizarLugar(lugar);
            return(RedirectToAction("Index"));
        }
Beispiel #17
0
        public void SetPeticion()
        {
            peticion = new PeticionLugarTuristico();

            lugar             = new LugarTuristico();
            lugar.Id          = idLugar;
            lugar.Nombre      = "Parque Generalisimo de Miranda";
            lugar.Costo       = 0;
            lugar.Descripcion = "Lugar al aire libre";
            lugar.Direccion   = "Frente a la estacion Miranda, Caracas";
            lugar.Correo      = "*****@*****.**";
            lugar.Telefono    = 02122732867;
            lugar.Latitud     = 20.0;
            lugar.Longitud    = 10.0;
            lugar.Activar     = true;

            byte[] imagen = new byte[28480];

            actividad                = new Actividad();
            actividad.Id             = idActividad;
            actividad.Nombre         = "Parque Generalisimo de Miranda";
            actividad.Duracion       = new TimeSpan(2, 0, 0);
            actividad.Descripcion    = "Lugar al aire libre";
            actividad.Foto.Contenido = imagen;
            actividad.Activar        = true;

            horario              = new Horario();
            horario.Id           = idHorario;
            horario.DiaSemana    = (int)DateTime.Now.DayOfWeek;
            horario.HoraApertura = new TimeSpan(8, 0, 0);
            horario.HoraCierre   = new TimeSpan(17, 0, 0);

            foto           = new Foto();
            foto.Id        = idFoto;
            foto.Contenido = imagen;

            lugar.Actividad.Add(actividad);
            lugar.Horario.Add(horario);
            lugar.Foto.Add(foto);
        }
Beispiel #18
0
        /// <summary>
        /// Consulta los lugares turisticos por nombre, o similiares.
        /// </summary>
        /// <param name="busqueda">Palabra cuya similitud se busca en el nombre del lugar turistico que se esta buscando.</param>
        /// <returns>Retorna una lista con los lugares turisticos que tengan coincidencia.</returns>
        public List <LugarTuristico> ConsultarLugarTuristico(string busqueda)
        {
            List <LugarTuristico> list_lugaresturisticos = new List <LugarTuristico>();

            try
            {
                con = new ConexionBase();
                con.Conectar();
                comm             = new NpgsqlCommand("consultar_lugarturistico", con.SqlConexion);
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.AddWithValue(NpgsqlTypes.NpgsqlDbType.Varchar, busqueda);
                pgread = comm.ExecuteReader();

                //Se recorre los registros devueltos.
                while (pgread.Read())
                {
                    LugarTuristico lugarTuristico = new LugarTuristico();
                    lugarTuristico.Id     = pgread.GetInt32(0);
                    lugarTuristico.Nombre = pgread.GetString(1);

                    list_lugaresturisticos.Add(lugarTuristico);
                }

                con.Desconectar();
                return(list_lugaresturisticos);
            }
            catch (NpgsqlException e)
            {
                con.Desconectar();
                throw e;
            }
            catch (Exception e)
            {
                con.Desconectar();
                throw e;
            }
        }
Beispiel #19
0
        /// <summary>
        /// Consulta los lugares turisticos por nombre, o similiares.
        /// </summary>
        /// <param name="busqueda">Palabra cuya similitud se busca en el nombre del lugar turistico que se esta buscando.</param>
        /// <returns>Retorna una lista con los lugares turisticos que tengan coincidencia.</returns>
        public List <Entidad> ConsultarLugarTuristico(Entidad objeto)
        {
            LugarTuristico lugarTuristico         = (LugarTuristico)objeto;
            List <Entidad> list_lugaresturisticos = new List <Entidad>();

            try
            {
                base.Conectar();
                comando             = new NpgsqlCommand("consultar_lugarturistico", base.SqlConexion);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue(NpgsqlTypes.NpgsqlDbType.Varchar, lugarTuristico.Nombre);
                respuesta = comando.ExecuteReader();

                //Se recorre los registros devueltos.
                while (respuesta.Read())
                {
                    LugarTuristico lugarTuristicos = new LugarTuristico();
                    lugarTuristicos.Id     = respuesta.GetInt32(0);
                    lugarTuristicos.Nombre = respuesta.GetString(1);

                    list_lugaresturisticos.Add(lugarTuristicos);
                }

                base.Desconectar();
                return(list_lugaresturisticos);
            }
            catch (NpgsqlException e)
            {
                base.Desconectar();
                throw e;
            }
            catch (Exception e)
            {
                base.Desconectar();
                throw e;
            }
        }
Beispiel #20
0
        public void SetPrueba()
        {
            usuario = new Usuario
            {
                Nombre          = "Carlos",
                Apellido        = "Valero",
                Genero          = "M",
                NombreUsuario   = "pepo",
                FechaNacimiento = new DateTime(2017, 03, 09),
                Correo          = "*****@*****.**",
                Clave           = "pruebaclave",
                Foto            = ""
            };

            usuariof = new Usuario
            {
                Nombre   = "pedro",
                Apellido = "garcia",
                Correo   = "*****@*****.**",
                Foto     = ""
            };


            evento1 = new EventoPreferencia
            {
                NombreEvento    = "predespachill",
                FechaInicio     = new DateTime(2019, 12, 12, 0, 0, 0),
                FechaFin        = new DateTime(2019, 12, 13, 0, 0, 0),
                HoraInicio      = new TimeSpan(20, 0, 0),
                HoraFin         = new TimeSpan(23, 0, 0),
                Precio          = 5000,
                Descripcion     = "pre despacho antes de beber en holic",
                NombreLocal     = "Holic",
                LocalFotoRuta   = "predespachill.jpg",
                NombreCategoria = "bar"
            };

            lugarTuristico1 = new LugarTuristicoPreferencia
            {
                NombreLT        = "Playa Pelua",
                Costo           = 0,
                Descripcion     = "Farandu Playa",
                Direccion       = "la guaira",
                LugarFotoRuta   = "pelua.jpg",
                NombreCategoria = "bar"
            };
            eve = new Evento {
                Nombre      = "predespachill",
                Descripcion = "pre despacho antes de beber en holic",
                Precio      = 5000,
                FechaInicio = new DateTime(2019, 12, 12, 0, 0, 0),
                FechaFin    = new DateTime(2019, 12, 13, 0, 0, 0),
                HoraInicio  = new DateTime().AddHours(20),
                HoraFin     = new DateTime().AddHours(23),
                Foto        = "predespachill.jpg",
                IdLocalidad = 1,
                IdCategoria = 1
            };
            categoria = new Categoria {
                Nombre            = "bar",
                Descripcion       = "Lugar para beber",
                Estatus           = true,
                CategoriaSuperior = 0,
                Nivel             = 0,
            };
            localidad = new ApiRest_COCO_TRIP.Datos.Entity.LocalidadEvento
            {
                Nombre      = "Holic",
                Descripcion = "Bar y discoteca",
                Coordenadas = "5.5"
            };
            lt = new LugarTuristico
            {
                Nombre      = "Plata Pelua",
                Costo       = 0,
                Descripcion = "Farandu Playa",
                Direccion   = "la guaira",
                Correo      = "*****@*****.**",
                Telefono    = 2893517,
                Latitud     = 5.3,
                Longitud    = 5.4,
                Activar     = true,
                Categoria   = new List <Categoria> {
                    categoria
                }
            };
            globalf = peticion.InsertarUsuarioFacebook(usuariof);
            global  = peticion.InsertarUsuario(usuario);

            /* peticion.InsertarCategoria(categoria);
             * peticionPerfil.AgregarPreferencia(usuario.Id, categoria.Id);
             * peticionLocalidadEvento.AgregarLocalidadEvento(localidad);
             * peticionEvento.AgregarEvento(eve);
             */
        }
Beispiel #21
0
 public void AddLugarTuristico(LugarTuristico lugar)
 {
     context.LugarTuristicos.Add(lugar);
     context.SaveChanges();
 }
Beispiel #22
0
        /// <summary>
        /// Metodo que se trae toda la lista de lugares turisticos
        /// </summary>
        /// <returns>Lista de lugares turisticos completa</returns>
        public List <Entidad> ConsultarTodaLaLista()
        {
            List <Entidad> lugaresTuristicos = new List <Entidad>();           // Estos new me hacen ruido aqui.

            try
            {
                StoredProcedure("ConsultarLugaresTuristico");
                _datos = Comando.ExecuteReader();

                while (_datos.Read())
                {
                    LugarTuristico lugarTuristico = FabricaEntidad.CrearEntidadLugarTuristico();
                    lugarTuristico.Id          = _datos.GetInt32(0);
                    lugarTuristico.Nombre      = _datos.GetString(1);
                    lugarTuristico.Costo       = _datos.GetDouble(2);
                    lugarTuristico.Descripcion = _datos.GetString(3);
                    lugarTuristico.Direccion   = _datos.GetString(4);
                    lugarTuristico.Correo      = _datos.GetString(5);
                    lugarTuristico.Telefono    = _datos.GetInt64(6);
                    lugarTuristico.Latitud     = _datos.GetDouble(7);
                    lugarTuristico.Longitud    = _datos.GetDouble(8);
                    lugarTuristico.Activar     = _datos.GetBoolean(9);
                    lugaresTuristicos.Add(lugarTuristico);
                }

                return(lugaresTuristicos);
            }
            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();
            }
        }
Beispiel #23
0
        public void SetUp()
        {
            _lugaresTuristicos          = new List <Entidad>();
            _lugarTuristico             = FabricaEntidad.CrearEntidadLugarTuristico();
            _lugarTuristico.Id          = 2;
            _lugarTuristico.Nombre      = "Parque Venezuela";
            _lugarTuristico.Costo       = 2000;
            _lugarTuristico.Descripcion = "Parque creado en Venezuela";
            _lugarTuristico.Direccion   = "Av. Principal Venezuela";
            _lugarTuristico.Correo      = "*****@*****.**";
            _lugarTuristico.Telefono    = 04142792806;
            _lugarTuristico.Latitud     = 25;
            _lugarTuristico.Longitud    = 25;
            _lugarTuristico.Activar     = true;

            _lugaresTuristicos.Add(_lugarTuristico);

            _lugarTuristico             = FabricaEntidad.CrearEntidadLugarTuristico();
            _lugarTuristico.Id          = 3;
            _lugarTuristico.Nombre      = "Parque Del este";
            _lugarTuristico.Costo       = 2000;
            _lugarTuristico.Descripcion = "Parque natural en Venezuela";
            _lugarTuristico.Direccion   = "En el este de caracas";
            _lugarTuristico.Correo      = "*****@*****.**";
            _lugarTuristico.Telefono    = 04164444778;
            _lugarTuristico.Latitud     = 25;
            _lugarTuristico.Longitud    = 25;
            _lugarTuristico.Activar     = true;

            _lugaresTuristicos.Add(_lugarTuristico);


            _fotos = new List <Entidad>();

            _foto      = FabricaEntidad.CrearEntidadFoto();
            _foto.Id   = 2;
            _foto.Ruta = "TEST";

            _fotos.Add(_foto);

            _foto      = FabricaEntidad.CrearEntidadFoto();
            _foto.Id   = 3;
            _foto.Ruta = "TEST2";

            _fotos.Add(_foto);

            // Guardo la primera foto de la lista
            _foto = (Foto)_fotos[0];

            _actividades = new List <Entidad>();

            _actividad             = FabricaEntidad.CrearEntidadActividad();
            _actividad.Id          = 2;
            _actividad.Nombre      = "TEST";
            _actividad.Foto.Ruta   = "TEST";
            _actividad.Duracion    = new TimeSpan(2, 0, 0);
            _actividad.Descripcion = "TEST";
            _actividad.Activar     = true;

            _actividades.Add(_actividad);

            _actividad             = FabricaEntidad.CrearEntidadActividad();
            _actividad.Id          = 3;
            _actividad.Nombre      = "TREMENDOTEST";
            _actividad.Foto.Ruta   = "CARACAS";
            _actividad.Duracion    = new TimeSpan(2, 0, 0);
            _actividad.Descripcion = "THE GREATEST ACTIVITY";
            _actividad.Activar     = true;

            _actividades.Add(_actividad);

            _categoria                   = FabricaEntidad.CrearEntidadCategoria();
            _categoria.Nombre            = "Musica";
            _categoria.Descripcion       = "Categoria asociada con la musica";
            _categoria.Estatus           = true;
            _categoria.Nivel             = 1;
            _categoria.CategoriaSuperior = 0;

            //_comandoA = FabricaComando.CrearComandoAgregarCategoria(_categoria);
            //_comandoA.Ejecutar();
        }
Beispiel #24
0
 public void TearDown()
 {
     _lugarTuristico    = null;
     _lugaresTuristicos = null;
 }
Beispiel #25
0
        public override Entidad ConsultarPorId(Entidad objeto)
        {
            LugarTuristico lugarTuristico = FabricaEntidad.CrearEntidadLugarTuristico();

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

                while (_datos.Read())
                {
                    lugarTuristico.Id          = objeto.Id;
                    lugarTuristico.Nombre      = _datos.GetString(0);
                    lugarTuristico.Costo       = _datos.GetDouble(1);
                    lugarTuristico.Descripcion = _datos.GetString(2);
                    lugarTuristico.Direccion   = _datos.GetString(3);
                    lugarTuristico.Correo      = _datos.GetString(4);
                    lugarTuristico.Telefono    = _datos.GetInt64(5);
                    lugarTuristico.Latitud     = _datos.GetDouble(6);
                    lugarTuristico.Longitud    = _datos.GetDouble(7);
                    lugarTuristico.Activar     = _datos.GetBoolean(8);
                }

                log.Info("Lugar turistico:" + lugarTuristico);

                return(lugarTuristico);
            }
            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();
            }
        }
 /// <summary>
 /// Constructor de la clase
 /// </summary>
 /// <param name="busqueda">coincidencia a ser comparadaa</param>
 public ComandoListarCoincidenciaLugaresTurisiticos(string busqueda)
 {
     lugarTuristico        = FabricaEntidad.CrearEntidadLugarTuristico();
     lugarTuristico.Nombre = busqueda;
 }