/// <summary> /// Renders the contents of the <see cref="T:System.Web.UI.WebControls.Label" /> into the /// specified writer. /// </summary> /// <param name="writer">The output stream that renders HTML content to the client.</param> protected override void RenderContents(HtmlTextWriter writer) { using (UnitOfWork uof = new UnitOfWork()) { var commentBo = new CommentBO(uof); int commentCount = commentBo.GetCommentCount(this.mParentIdValue); writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClass); writer.RenderBeginTag(HtmlTextWriterTag.Span); if (commentCount > 0) { //// writer.Write(String.Format(Me._text, commentCount)) if (this.mTextValue == null) { writer.Write(string.Format(Localization.GetString("FeedBack.Text", WikiModuleBase.SharedResources), commentCount)); } else { writer.Write(string.Format(this.mTextValue, commentCount)); } } else { writer.Write(Localization.GetString("NoComments.Text", WikiModuleBase.SharedResources)); } writer.RenderEndTag(); } }
private void ajax_getcomment(string id, int page) { using (CommentBO cm = new CommentBO(id, page - 1)) { Response.Write(cm.getCommentContent()); } }
public void TestListCommentAsync() { ApplicationSeeder.Seed(); var bo = new CommentBO(); var resList = bo.ListAsync().Result; Assert.IsTrue(resList.Success && resList.Result.Count > 0); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Unload" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains event /// data.</param> protected override void OnUnload(EventArgs e) { if (this.mUnitOfWork != null) { this.mUnitOfWork.Dispose(); this.mUnitOfWork = null; } if (this.mCommentBOObject != null) { this.mCommentBOObject = null; } }
public void TestCreateAndListCommentAsync() { ApplicationSeeder.Seed(); var bo = new CommentBO(); var foreignBO = new ClientBO(); var comment = new Comment("Tou só a testar", foreignBO.ListUndeleted().Result.First().Id); var resCreate = bo.CreateAsync(comment).Result; var resGet = bo.ReadAsync(comment.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
//Map from the BusinessLogic to the Presentation public static CommentPO CommentBOtoPO(CommentBO from) { CommentPO to = new CommentPO(); to.CommentID = from.CommentID; to.CommentTime = from.CommentTime; to.CommentText = from.CommentText; to.Rating = from.Rating; to.GameID = from.GameID; to.UserID = from.UserID; to.Username = from.Username; to.GameName = from.GameName; return(to); }
public void TestDeleteCommentAsync() { ApplicationSeeder.Seed(); var bo = new CommentBO(); var resList = bo.ListAsync().Result; var total = resList.Result.Count; var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result; var list = bo.ListUndeletedAsync().Result; Assert.IsTrue(resDelete.Success && resList.Success && list.Result.Count == (total - 1)); }
public void TestUpdateCommentAsync() { ApplicationSeeder.Seed(); var bo = new CommentBO(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.Message = "Tou só a editar"; var resUpdate = bo.UpdateAsync(item).Result; var list = bo.ListUndeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().Message == "Tou só a editar"); }
/// <summary> /// Handles the Click event of the SubmitButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event /// data.</param> private void SubmitButton_Click(object sender, System.EventArgs e) { using (UnitOfWork uOw = new UnitOfWork()) { var commentBo = new CommentBO(uOw); string commentText = this.txtComment.Text; DotNetNuke.Security.PortalSecurity objSec = new DotNetNuke.Security.PortalSecurity(); if (commentText.Length > this.CommentsMaxLength) { commentText = commentText.Substring(0, this.CommentsMaxLength); } ////4.8.3 has better control for NoMarkup var comment = new Comment { ParentId = this.ParentId, Name = objSec.InputFilter(this.txtName.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup), Email = objSec.InputFilter(this.txtEmail.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup), CommentText = objSec.InputFilter(commentText, PortalSecurity.FilterFlag.NoMarkup), Ip = objSec.InputFilter(this.Context.Request.ServerVariables["REMOTE_ADDR"], DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup), EmailNotify = this.chkSubscribeToNotifications.Checked, Datetime = DateTime.Now }; comment = commentBo.Add(comment); ////send the notification var topic = new TopicBO(uOw).Get(this.ParentId); DNNUtils.SendNotifications(uOw, topic, comment.Name, comment.Email, comment.CommentText, comment.Ip); this.mSuccessValue = comment.CommentId > 0; if (this.mSuccessValue) { this.txtName.Text = string.Empty; this.txtEmail.Text = string.Empty; this.txtComment.Text = string.Empty; this.Context.Cache.Remove("WikiComments" + this.ParentId.ToString()); if (this.PostSubmitted != null) { this.PostSubmitted(this); } } } }
public List <CommentBO> GetAllComments(int eventId) { List <CommentBO> list = new List <CommentBO>(); sqlCommand = new SqlCommand() { Connection = connectionHelper.connection, CommandType = CommandType.StoredProcedure, CommandText = "GetAllCommentsSP", }; sqlCommand.Parameters.Add("@EventId", SqlDbType.Int).Value = eventId; connectionHelper.connection.Open(); SqlDataReader sqlReader = sqlCommand.ExecuteReader(); if (sqlReader.HasRows) { while (sqlReader.Read()) { var model = new CommentBO() { Id = Convert.ToInt32(sqlReader["Id"]), PersonId = Convert.ToInt32(sqlReader["PersonId"]), Content = sqlReader["Content"] as string, Title = sqlReader["Title"] as string, PersonName = sqlReader["PersonName"] as string, Date = (DateTime)sqlReader["Date"] }; list.Add(model); } } connectionHelper.connection.Close(); return(list); }