void DisplayWatchLaterFilms(Int32 userId)
 {
     try
     {
         clsDataConnection DB = new clsDataConnection();
         DB.AddParameter("@UserId", userId);
         DB.Execute("sproc_tblWatchList_FilterByUserId");
         Int32  recordCount = DB.Count;
         Int32  index       = 0;
         Int32  filmId      = 0;
         string title;
         if (recordCount == 0)
         {
             clsDynamicPanel aDynamicPanel = new clsDynamicPanel();
             pnlWatchList.Controls.Add(aDynamicPanel.GenerateEmptyListPanel("watch list"));
         }
         else
         {
             bool favourite      = false;
             bool displayOverlay = true;
             while (index < recordCount)
             {
                 filmId = Convert.ToInt32(DB.DataTable.Rows[index]["FilmId"]);
                 title  = DB.DataTable.Rows[index]["Title"].ToString();
                 pnlWatchList.Controls.Add(anImdbApi.GetImdbInformationWithOptions(filmId, title, userId, favourite, displayOverlay));
                 index++;
             }
         }
         pnlWatchList.Visible = true;
     }
     catch
     {
         pnlError.Visible = true;
     }
 }
        protected void ddlGenre_SelectedIndexChanged(object sender, EventArgs e)
        {
            Int32             genreId       = ddlGenre.SelectedIndex;
            clsDataConnection DB            = new clsDataConnection();
            clsDynamicPanel   aDynamicPanel = new clsDynamicPanel();

            string searchText = Session["searchText"].ToString();

            DB.AddParameter("@Title", searchText);
            DB.AddParameter("@GenreId", genreId);
            DB.Execute("sproc_tblFilm_CollateWithTblFilmGenreAndLinks");
            Int32 recordCount = DB.Count;
            Int32 index       = 0;

            if (recordCount != 0)
            {
                pnlActualSearchResults.Controls.Clear();
                while (index < recordCount)
                {
                    string title  = DB.DataTable.Rows[index]["Title"].ToString();
                    string imdbId = DB.DataTable.Rows[index]["ImdbId"].ToString();

                    pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateSearchResultsPanel(title, imdbId));
                    index++;
                }
            }
            else
            {
                pnlActualSearchResults.Controls.Clear();
                pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateEmptySearchResultsPanel());
            }
            pnlAllSearchResults.Visible = true;
        }
 void DisplayRecommendedFilms(Int32 userId)
 {
     try
     {
         clsDataConnection DB = new clsDataConnection();
         DB.AddParameter("@UserId", userId);
         DB.Execute("sproc_tblFilmRecommendation_FilterByUserId");
         Int32 recordCount = DB.Count;
         Int32 index       = 0;
         Int32 filmId      = 0;
         if (recordCount == 0)
         {
             clsDynamicPanel aDynamicPanel = new clsDynamicPanel();
             pnlRecommendations.Controls.Add(aDynamicPanel.GenerateEmptyListPanel("recommended films"));
         }
         else
         {
             while (index < recordCount)
             {
                 filmId = Convert.ToInt32(DB.DataTable.Rows[index]["FilmId"]);
                 pnlRecommendations.Controls.Add(anImdbApi.GetImdbInformation(filmId));
                 index++;
             }
         }
         pnlRecommendations.Visible = true;
     }
     catch
     {
         pnlError.Visible = true;
     }
 }
        void CheckIfUserIsLoggedIn()
        {
            bool userLoggedIn = HttpContext.Current.User.Identity.IsAuthenticated;

            if (userLoggedIn)
            {
                clsDynamicPanel aDynamicPanel = new clsDynamicPanel();
                pnlNavBar.Controls.Clear();
                pnlNavBar.CssClass = "navbar";
                pnlNavBar.Controls.Add(aDynamicPanel.GenerateMyAccountDropDown());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            pnlAllSearchResults.Visible = false;
            pnlError.Visible            = false;

            if (!IsPostBack)
            {
                try
                {
                    string searchText = Request.QueryString["searchText"];
                    Session["searchText"] = searchText;
                    CheckIfUserIsLoggedIn();

                    clsFilmCollection AllFilms      = new clsFilmCollection();
                    clsDataConnection DB            = new clsDataConnection();
                    clsDynamicPanel   aDynamicPanel = new clsDynamicPanel();

                    if (AllFilms.SearchForFilm(searchText).Count != 0)
                    {
                        foreach (clsFilm aFilm in AllFilms.SearchForFilm(searchText))
                        {
                            DB = new clsDataConnection();
                            DB.AddParameter("@FilmId", aFilm.FilmId);
                            DB.Execute("sproc_tblLinksFilterByFilmId");

                            string imdbId = DB.DataTable.Rows[0]["ImdbId"].ToString();
                            pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateSearchResultsPanel(aFilm.Title, imdbId));
                        }
                        GenerateMoods();
                        pnlAllSearchResults.Visible = true;
                    }
                    else
                    {
                        pnlActualSearchResults.Controls.Clear();
                        pnlActualSearchResults.Controls.Add(aDynamicPanel.GenerateEmptySearchResultsPanel());
                    }
                }
                catch
                {
                    pnlError.Visible = true;
                }
            }
        }