/// <summary> /// Function for update the approve status of comments. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ApproveSelectedComment(object sender, EventArgs e) { if (Pub.Any()) { foreach (GridViewRow row in GridComments.Rows) { // Access the CheckBox CheckBox cb = (CheckBox)row.FindControl("chkPublish"); if (cb != null && cb.Checked && !Pub[row.DataItemIndex].Approved) { Pub[row.DataItemIndex].Approved = true; _objRepository.Update(Pub[row.DataItemIndex]); string userEmail = Pub[row.DataItemIndex].Email; Database context = Sitecore.Context.ContentDatabase; GetSettings getSettings = new GetSettings(); var settingsValue = getSettings.GetSetting(Result, context); if (settingsValue.UserEmail && !string.IsNullOrEmpty(settingsValue.FromEmail) && !string.IsNullOrEmpty(userEmail) && !string.IsNullOrEmpty(settingsValue.UserMsgSubject) && !string.IsNullOrEmpty(settingsValue.UserMsgBody)) { Utility.SendMail(settingsValue.FromEmail, userEmail, settingsValue.UserMsgSubject, settingsValue.UserMsgBody); } } else if (cb != null && !cb.Checked && Pub[row.DataItemIndex].Approved) { Pub[row.DataItemIndex].Approved = false; _objRepository.Update(Pub[row.DataItemIndex]); } } } }
protected void DeleteSelectedComment(object sender, EventArgs e) { if (Pub.Any()) { foreach (GridViewRow row in GridComments.Rows) { // Access the CheckBox CheckBox cb = (CheckBox)row.FindControl("chkDelete"); if (cb != null && cb.Checked) { _objBlogRepository.DeleteComment(Pub[row.DataItemIndex].Id); } } } }
private void LoadComments() { if (Pub.Any()) { lblcommentstatus.Visible = false; GridComments.DataSource = Pub; GridComments.DataBind(); btnPublish.Visible = true; btnDelete.Visible = true; CheckPublishComment(); } else { lblcommentstatus.Visible = true; lblcommentstatus.Text = "No comments found"; } }
protected void CheckPublishComment() { if (Pub.Any()) { foreach (GridViewRow row in GridComments.Rows) { // Access the CheckBox CheckBox cb = (CheckBox)row.FindControl("chkPublish"); if (cb != null) { var approveStatus = Pub[row.DataItemIndex].Approved; if (approveStatus) { cb.Checked = true; } } } } }
protected void PublishSelectedComment(object sender, EventArgs e) { if (Pub.Any()) { foreach (GridViewRow row in GridComments.Rows) { // Access the CheckBox CheckBox cb = (CheckBox)row.FindControl("chkPublish"); if (cb != null && cb.Checked && !Pub[row.DataItemIndex].Approved) { Pub[row.DataItemIndex].Approved = true; _objBlogRepository.UpdateComment(Pub[row.DataItemIndex]); } else if (cb != null && !cb.Checked && Pub[row.DataItemIndex].Approved) { Pub[row.DataItemIndex].Approved = false; _objBlogRepository.UpdateComment(Pub[row.DataItemIndex]); } } } }
/// <summary> /// Load all the comments in sitecore comment editor. /// </summary> private void LoadComments() { GetCommonSettings newGetCommonSettings = new GetCommonSettings(); Database context = Sitecore.Context.ContentDatabase; var commonSetting = newGetCommonSettings.GetCommonSetting(context); if (Pub.Any()) { lblcommentstatus.Visible = false; GridComments.PageSize = commonSetting.PageSize; GridComments.DataSource = Pub; GridComments.DataBind(); btnPublish.Visible = true; btnDelete.Visible = true; CheckApproveComment(); } else { lblcommentstatus.Visible = true; lblcommentstatus.Text = "No comments found"; } }