Esempio n. 1
0
        private void DoSearch(string searchTerm)
        {
            var searchResults = Media.Search(searchTerm, myUser.Id);

            MediaTitle.InnerText = searchResults.Media.Count > 0 ? "Content found:" : "No content was found using those search terms :(";


            TagsTitle.InnerText = (searchResults.MediaTags.Count > 0 || searchResults.Users.Count > 0) ? "Tags found:" : "No tags were found using those search terms :(";

            Page httpHandler = (Page)HttpContext.Current.Handler;
            List <ViewTagControl> ViewTagControls = new List <ViewTagControl>();

            foreach (MediaTag mediaTag in searchResults.MediaTags)
            {
                ViewTagControl mediaTagPairViewControl = (ViewTagControl)httpHandler.LoadControl("~/Custom_Controls/Media/ViewTagControl.ascx");
                mediaTagPairViewControl.MyTag = mediaTag;
                mediaTagPairViewControl.UpdateLink();
                MediaTagContainer.Controls.Add(mediaTagPairViewControl);
                ViewTagControls.Add(mediaTagPairViewControl);
            }

            foreach (ParsnipData.Accounts.User user in searchResults.Users)
            {
                ViewTagControl mediaUserPairViewControl = (ViewTagControl)httpHandler.LoadControl("~/Custom_Controls/Media/ViewTagControl.ascx");
                mediaUserPairViewControl.MyUser = user;
                mediaUserPairViewControl.UpdateLink();
                MediaTagContainer.Controls.Add(mediaUserPairViewControl);
                ViewTagControls.Add(mediaUserPairViewControl);
            }

            foreach (ViewTagControl control in ViewTagControls.OrderBy(x => x.Name))
            {
                MediaTagContainer.Controls.Add(control);
            }

            foreach (var mediaControl in MediaControl.GetMediaSearchResultAsMediaControls(searchResults))
            {
                MediaContainer.Controls.Add(mediaControl);
            }
        }