protected void BindData() { try { if (!String.IsNullOrEmpty(txtSearchTerm.Text)) { //can be removed if (String.IsNullOrEmpty(txtSearchTerm.Text)) { throw new NopException(LocalizationManager.GetLocaleResourceString("Forum.SearchTermCouldNotBeEmpty")); } if (txtSearchTerm.Text.Length < 3) { throw new NopException(LocalizationManager.GetLocaleResourceString("Forum.SearchTermMinimumLengthIs3Characters")); } string keywords = txtSearchTerm.Text; int totalRecords = 0; int pageSize = 10; if (ForumManager.SearchResultsPageSize > 0) { pageSize = ForumManager.SearchResultsPageSize; } ForumTopicCollection forumTopics = ForumManager.GetAllTopics(0, 0, keywords, true, pageSize, this.CurrentPageIndex, out totalRecords); if (forumTopics.Count > 0) { this.searchPager1.PageSize = pageSize; this.searchPager1.TotalRecords = totalRecords; this.searchPager1.PageIndex = this.CurrentPageIndex; this.searchPager2.PageSize = pageSize; this.searchPager2.TotalRecords = totalRecords; this.searchPager2.PageIndex = this.CurrentPageIndex; rptrSearchResults.DataSource = forumTopics; rptrSearchResults.DataBind(); } rptrSearchResults.Visible = (forumTopics.Count > 0); lblNoResults.Visible = !(rptrSearchResults.Visible); } else { rptrSearchResults.Visible = false; } } catch (Exception exc) { rptrSearchResults.Visible = false; lblError.Text = Server.HtmlEncode(exc.Message); } }
private void BindData() { if (!ForumManager.ForumsEnabled) { this.Visible = false; return; } ForumTopicCollection forumTopics = ForumManager.GetActiveTopics(this.ForumID); if (forumTopics.Count > 0) { rptrTopics.DataSource = forumTopics; rptrTopics.DataBind(); } else { this.Visible = false; } }
protected void BindData() { Forum forum = ForumManager.GetForumByID(this.ForumID); if (forum != null) { //hlNewTopic.Visible = ForumManager.IsUserAllowedToCreateTopic(NopContext.Current.User, forum); lblForumName.Text = Server.HtmlEncode(forum.Name); lblForumDescription.Text = Server.HtmlEncode(forum.Description); hlNewTopic.NavigateUrl = SEOHelper.GetNewForumTopicURL(forum.ForumID); int totalRecords = 0; int pageSize = 10; if (ForumManager.TopicsPageSize > 0) { pageSize = ForumManager.TopicsPageSize; } ForumTopicCollection forumTopics = ForumManager.GetAllTopics(forum.ForumID, 0, string.Empty, false, pageSize, this.CurrentPageIndex, out totalRecords); if (forumTopics.Count > 0) { this.topicsPager1.PageSize = pageSize; this.topicsPager1.TotalRecords = totalRecords; this.topicsPager1.PageIndex = this.CurrentPageIndex; this.topicsPager2.PageSize = pageSize; this.topicsPager2.TotalRecords = totalRecords; this.topicsPager2.PageIndex = this.CurrentPageIndex; rptrTopics.DataSource = forumTopics; rptrTopics.DataBind(); } //subsciption if (ForumManager.IsUserAllowedToSubscribe(NopContext.Current.User)) { ForumSubscription forumSubscription = ForumManager.GetAllSubscriptions(NopContext.Current.User.CustomerID, forum.ForumID, 0, 1, 0).FirstOrDefault(); if (forumSubscription == null) { btnWatchForum.Text = GetLocaleResourceString("Forum.WatchForum"); } else { btnWatchForum.Text = GetLocaleResourceString("Forum.UnwatchForum"); } } else { btnWatchForum.Visible = false; } } else { Response.Redirect(SEOHelper.GetForumMainURL()); } }
private static ForumTopicCollection DBMapping(DBForumTopicCollection dbCollection) { if (dbCollection == null) return null; ForumTopicCollection collection = new ForumTopicCollection(); foreach (DBForumTopic dbItem in dbCollection) { ForumTopic item = DBMapping(dbItem); collection.Add(item); } return collection; }