<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim movies = GetMovies()
        Dim genres = GetGenres()
        
        Dim query = From m In movies Join g In genres _
                    On m.Genre Equals g.ID _
                    Select New With {.Title = m.Title, .Genre = g.Name}
        
        GridView1.DataSource = query
        GridView1.DataBind()
    End Sub

    Public Function GetGenres() As List(Of Chapter9.Genre)
        Dim genres As Chapter9.Genre() = { _
            New Chapter9.Genre With {.ID = 0, .Name = "Comedy"}, _
            New Chapter9.Genre With {.ID = 1, .Name = "Drama"}, _
            New Chapter9.Genre With {.ID = 2, .Name = "Action"} _
        }

        Return New List(Of Chapter9.Genre)(genres)
    End Function

    Public Function GetMovies() As List(Of Movie)
        Dim movies As Movie() = { _
            New Movie With {.Title = "Shrek", .Director = "Andrew Adamson", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("5/16/2001"), .Runtime = 89}, _
            New Movie With {.Title = "Fletch", .Director = "Michael Ritchie", _
                 .Genre = 0, .ReleaseDate = DateTime.Parse("5/31/1985"), .Runtime = 96}, _
            New Movie With {.Title = "Casablanca", .Director = "Michael Curtiz", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("1/1/1942"), .Runtime = 102}, _
            New Movie With {.Title = "Batman", .Director = "Tim Burton", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("6/23/1989"), .Runtime = 126}, _
            New Movie With {.Title = "Dances with Wolves", .Director = "Kevin Costner", _
                 .Genre = 1, .ReleaseDate = DateTime.Parse("11/21/1990"), .Runtime = 180}, _
            New Movie With {.Title = "Dirty Dancing", .Director = "Emile Ardolino", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("8/21/1987"), .Runtime = 100}, _
            New Movie With {.Title = "The Parent Trap", .Director = "Nancy Meyers", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("7/29/1998"), .Runtime = 127}, _
            New Movie With {.Title = "Ransom", .Director = "Ron Howard", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("11/8/1996"), .Runtime = 121}, _
            New Movie With {.Title = "Ocean’s Eleven", .Director = "Steven Soderbergh", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("12/7/2001"), .Runtime = 116}, _
            New Movie With {.Title = "Steel Magnolias", .Director = "Herbert Ross", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("11/15/1989"), .Runtime = 117}, _
            New Movie With {.Title = "Mystic Pizza", .Director = "Donald Petrie", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("10/21/1988"), .Runtime = 104}, _
            New Movie With {.Title = "Pretty Woman", .Director = "Garry Marshall", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("3/23/1990"), .Runtime = 119}, _
            New Movie With {.Title = "Interview with the Vampire", .Director = "Neil Jordan", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("11/11/1994"), .Runtime = 123}, _
            New Movie With {.Title = "Top Gun", .Director = "Tony Scott", _
                  .Genre = 2, .ReleaseDate = DateTime.Parse("5/16/1986"), .Runtime = 110}, _
            New Movie With {.Title = "Mission Impossible", .Director = "Brian De Palma", _
                  .Genre = 2, .ReleaseDate = DateTime.Parse("5/22/1996"), .Runtime = 110}, _
            New Movie With {.Title = "The Godfather", .Director = "Francis Ford Coppola", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("3/24/1972"), .Runtime = 175}, _
            New Movie With {.Title = "Carlito’s Way", .Director = "Brian De Palma", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("11/10/1993"), .Runtime = 144}, _
            New Movie With {.Title = "Robin Hood: Prince of Thieves", _
                  .Director = "Kevin Reynolds", .Genre = 1, _
                  .ReleaseDate = DateTime.Parse("6/14/1991"), .Runtime = 143}, _
            New Movie With {.Title = "The Haunted", .Director = "Robert Mandel", _
                 .Genre = 1, .ReleaseDate = DateTime.Parse("5/6/1991"), .Runtime = 100}, _
            New Movie With {.Title = "Old School", .Director = "Todd Phillips", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("2/21/2003"), .Runtime = 91}, _
            New Movie With {.Title = "Anchorman: The Legend of Ron Burgundy", _
                 .Director = "Adam McKay", .Genre = 0, _
                 .ReleaseDate = DateTime.Parse("7/9/2004"), .Runtime = 94}, _
            New Movie With {.Title = "Bruce Almighty", .Director = "Tom Shadyac", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("5/23/2003"), .Runtime = 101}, _
            New Movie With {.Title = "Ace Ventura: Pet Detective", _
                  .Director = "Tom Shadyac", .Genre = 0, _
                  .ReleaseDate = DateTime.Parse("2/4/1994"), .Runtime = 86}, _
            New Movie With {.Title = "Goonies", .Director = "Richard Donner", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("6/7/1985"), .Runtime = 114}, _
            New Movie With {.Title = "Sixteen Candles", .Director = "John Hughes", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("5/4/1984"), .Runtime = 93}, _
            New Movie With {.Title = "The Breakfast Club", .Director = "John Hughes", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("2/15/1985"), .Runtime = 97}, _
            New Movie With {.Title = "Pretty in Pink", .Director = "Howard Deutch", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("2/28/1986"), .Runtime = 96}, _
            New Movie With {.Title = "Weird Science", .Director = "John Hughes", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("8/2/1985"), .Runtime = 94}, _
            New Movie With {.Title = "Breakfast at Tiffany’s", .Director = "Blake Edwards", _
                  .Genre = 1, .ReleaseDate = DateTime.Parse("10/5/1961"), .Runtime = 115}, _
            New Movie With {.Title = "The Graduate", .Director = "Mike Nichols", _
                 .Genre = 1, .ReleaseDate = DateTime.Parse("4/2/1968"), .Runtime = 105}, _
            New Movie With {.Title = "Dazed and Confused", .Director = "Richard Linklater", _
                  .Genre = 0, .ReleaseDate = DateTime.Parse("9/24/1993"), .Runtime = 103}, _
            New Movie With {.Title = "Arthur", .Director = "Steve Gordon", _
                 .Genre = 1, .ReleaseDate = DateTime.Parse("9/25/1981"), .Runtime = 97}, _
            New Movie With {.Title = "Monty Python and the Holy Grail", _
                 .Director = "Terry Gilliam", .Genre = 0, _
                 .ReleaseDate = DateTime.Parse("5/10/1975"), .Runtime = 91}, _
              New Movie With {.Title = "Dirty Harry", .Director = "Don Siegel", _
                 .Genre = 2, .ReleaseDate = DateTime.Parse("12/23/1971"), .Runtime = 102} _
              }

        Return New List(Of Movie)(movies)
    End Function
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>   
    </div>
    </form>
</body>
</html>
