Пример #1
0
 /// <summary>
 /// Metodo para ejecuta el comando eliminar
 /// </summary>
 /// <returns></returns>
 public override bool ejecutar()
 {
     try
     {
         IDAORestaurant restaurantDao = FabricaDAO.RestaurantBD();
         restaurantDao.Eliminar(this._objeto);
         return(true);
     }
     catch (NotImplementedException e)
     {
         throw new ExceptionReserva("Reserva-404", "Metodo no implementado", e);
     }
     catch (Exception e)
     {
         throw new ExceptionReserva("Reserva-404", "Error al Realizar Operacion", e);
     }
 }
Пример #2
0
        public void M10_DaoEliminar()
        {
            restaurantDao = FabricaDAO.RestaurantBD();
            //Parametros para crear el nuevo registro en la base de datos
            ((CRestauranteModelo)restaurant).nombre          = "ItalyFood";
            ((CRestauranteModelo)restaurant).descripcion     = "Comida Italiana";
            ((CRestauranteModelo)restaurant).direccion       = "Antiamano";
            ((CRestauranteModelo)restaurant).Telefono        = "0212-5896699";
            ((CRestauranteModelo)restaurant).horarioApertura = "09:00";
            ((CRestauranteModelo)restaurant).horarioCierre   = "21:00";
            ((CRestauranteModelo)restaurant).idLugar         = 12;
            Resultado = restaurantDao.Crear(restaurant);

            //Verificar si el resultado fue exitoso
            Assert.AreEqual(Resultado, true);

            Entidad       rest            = FabricaEntidad.crearRestaurant();
            String        StringConection = restaurantDao.ConectionString();
            String        sqlString       = "SELECT TOP 1 rst_id FROM Restaurante where fk_lugar = 12 ORDER BY rst_id DESC;";
            SqlConnection conexion        = new SqlConnection(StringConection);

            conexion.Open();
            SqlCommand    cmd    = new SqlCommand(sqlString, conexion);
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            int idRestaurant = int.Parse(reader["rst_id"].ToString());

            IDAORestaurant restaurantDao1 = FabricaDAO.RestaurantBD();

            restaurante._id = idRestaurant;
            Boolean Resultado2 = restaurantDao1.Eliminar(restaurante);

            //Verificar si el resultado fue exitoso
            Assert.AreEqual(Resultado2, true);
        }