// GET: api/Evento/5
        public clsEventoDatos Get(int id)
        {
            clsEventoDatos eventoDatos = new clsEventoDatos();

            try
            {
                eventoDatos = clsGestoraEventoBL.obtenerDatosEvento(id);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.ServiceUnavailable);
            }
            return(eventoDatos);
        }
        /// <summary>
        /// Este método obtiene de la base de datos todos los datos de un evento
        /// </summary>
        /// <param name="id">El id del evento</param>
        /// <returns>Los datos del evento</returns>
        public static clsEventoDatos obtenerDatosEvento(int id)
        {
            clsMyConnection conexion      = new clsMyConnection();
            SqlConnection   sqlConnection = new SqlConnection();
            SqlCommand      command       = new SqlCommand();
            SqlCommand      command2      = new SqlCommand(); //ESTE ES PARA OBTENER LOS POSTS QUE EXISTEN EN EL EVENTO
            clsEventoDatos  eventoDatos   = new clsEventoDatos();
            clsEvento       evento;
            clsPost         post;
            List <clsPost>  listadoPosts = new List <clsPost>();
            SqlDataReader   reader;

            command.Parameters.AddWithValue("@ID", id);
            command2.Parameters.AddWithValue("@ID", id);
            command.CommandText  = "SELECT ID, Cartel, Fecha, Informacion, Lugar, Genero, Titulo, Nombre, S.Localidad, S.Direccion FROM Evento AS E INNER JOIN Usuario AS U ON E.Lugar = U.Nick INNER JOIN Sala AS S ON U.Nick = S.Nick WHERE ID = @ID";
            command2.CommandText = "SELECT NickUsuario, Contenido, FechaPost, Imagen FROM Post AS P INNER JOIN Evento AS E ON P.IDEvento = E.ID INNER JOIN Usuario AS U ON P.NickUsuario = U.Nick WHERE ID = @ID ORDER BY FechaPost DESC";

            try
            {
                sqlConnection      = conexion.getConnection();
                command.Connection = sqlConnection;
                reader             = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        eventoDatos               = new clsEventoDatos();
                        evento                    = new clsEvento();
                        evento.Id                 = (int)reader["ID"];
                        evento.Cartel             = (String)reader["Cartel"];
                        evento.Fecha              = (DateTime)reader["Fecha"];
                        evento.Informacion        = (String)reader["Informacion"];
                        evento.Lugar              = (String)reader["Lugar"];
                        eventoDatos.Evento        = evento;
                        eventoDatos.Evento.Genero = (String)reader["Genero"];
                        eventoDatos.Evento.Titulo = (String)reader["Titulo"];
                        eventoDatos.NombreSala    = (String)reader["Nombre"];
                        eventoDatos.Localidad     = (String)reader["Localidad"];
                        eventoDatos.Direccion     = (String)reader["Direccion"];
                    }
                }
                reader.Close();

                command2.Connection = sqlConnection;
                reader = command2.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        post             = new clsPost();
                        post.NickUsuario = (String)reader["NickUsuario"];
                        post.Contenido   = (String)reader["Contenido"];
                        post.Fecha       = (DateTime)reader["FechaPost"];
                        post.Imagen      = (String)reader["Imagen"];
                        listadoPosts.Add(post);
                    }
                    eventoDatos.Posts = listadoPosts;
                }
                reader.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            finally
            {
                conexion.closeConnection(ref sqlConnection);
            }
            return(eventoDatos);
        }