private void BindData() { News news = NewsManager.GetNewsByID(this.NewsID); if (news != null) { CommonHelper.SelectListItem(this.ddlLanguage, news.LanguageID); this.txtTitle.Text = news.Title; this.txtShort.Text = news.Short; this.txtFull.Value = news.Full; this.cbPublished.Checked = news.Published; this.cbAllowComments.Checked = news.AllowComments; this.pnlCreatedOn.Visible = true; this.lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(news.CreatedOn).ToString(); NewsCommentCollection newsComments = news.NewsComments; if (newsComments.Count > 0) { this.hlViewComments.Visible = true; this.hlViewComments.Text = string.Format(GetLocaleResourceString("Admin.NewsInfo.ViewComments"), newsComments.Count); this.hlViewComments.NavigateUrl = CommonHelper.GetStoreAdminLocation() + "NewsComments.aspx?NewsID=" + news.NewsID; } else { this.hlViewComments.Visible = false; } } else { this.pnlCreatedOn.Visible = false; this.hlViewComments.Visible = false; } }
/// <summary> /// Gets all news comments /// </summary> /// <returns>News comment collection</returns> public static NewsCommentCollection GetAllNewsComments() { DBNewsCommentCollection dbCollection = DBProviderManager <DBNewsProvider> .Provider.GetAllNewsComments(); NewsCommentCollection collection = DBMapping(dbCollection); return(collection); }
/// <summary> /// Gets a news comment collection by news identifier /// </summary> /// <param name="NewsID">The news identifier</param> /// <returns>News comment collection</returns> public static NewsCommentCollection GetNewsCommentsByNewsID(int NewsID) { DBNewsCommentCollection dbCollection = DBProviderManager <DBNewsProvider> .Provider.GetNewsCommentsByNewsID(NewsID); NewsCommentCollection collection = DBMapping(dbCollection); return(collection); }
protected void BindData() { NewsCommentCollection newsCommentCollection = null; if (this.NewsID > 0) { newsCommentCollection = NewsManager.GetNewsCommentsByNewsID(NewsID); } else { newsCommentCollection = NewsManager.GetAllNewsComments(); } lvNewsComments.DataSource = newsCommentCollection; lvNewsComments.DataBind(); }
private void BindData() { pnlError.Visible = false; News news = NewsManager.GetNewsByID(this.NewsID); if (news != null && news.Published) { this.lTitle.Text = Server.HtmlEncode(news.Title); this.lCreatedOn.Text = DateTimeHelper.ConvertToUserTime(news.CreatedOn).ToString(); this.lFull.Text = news.Full; if (news.AllowComments) { if (!NewsManager.AllowNotRegisteredUsersToLeaveComments && (NopContext.Current.User == null || NopContext.Current.User.IsGuest)) { lblLeaveYourComment.Text = GetLocaleResourceString("News.OnlyRegisteredUsersCanLeaveComments"); txtTitle.Enabled = false; txtComment.Enabled = false; btnComment.Enabled = false; } else { lblLeaveYourComment.Text = GetLocaleResourceString("News.LeaveYourComment"); txtTitle.Enabled = true; txtComment.Enabled = true; btnComment.Enabled = true; } NewsCommentCollection newsComments = news.NewsComments; if (newsComments.Count > 0) { rptrComments.DataSource = newsComments; rptrComments.DataBind(); } } else { pnlComments.Visible = false; } } else { Response.Redirect("~/Default.aspx"); } }
private static NewsCommentCollection DBMapping(DBNewsCommentCollection dbCollection) { if (dbCollection == null) { return(null); } NewsCommentCollection collection = new NewsCommentCollection(); foreach (DBNewsComment dbItem in dbCollection) { NewsComment item = DBMapping(dbItem); collection.Add(item); } return(collection); }