コード例 #1
0
        /// <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();
            }
        }
コード例 #2
0
 private void ajax_getcomment(string id, int page)
 {
     using (CommentBO cm = new CommentBO(id, page - 1))
     {
         Response.Write(cm.getCommentContent());
     }
 }
コード例 #3
0
        public void TestListCommentAsync()
        {
            ApplicationSeeder.Seed();

            var bo = new CommentBO();

            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count > 0);
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        //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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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");
        }
コード例 #9
0
ファイル: AddCommentsForm.cs プロジェクト: hnjm/DNN.Wiki
        /// <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);
                    }
                }
            }
        }
コード例 #10
0
ファイル: CommentDAL.cs プロジェクト: esdonmez/Evant_Info
        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);
        }
コード例 #11
0
ファイル: CommentCount.cs プロジェクト: JosephAllen/DNNWiki
        /// <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();
            }
        }
コード例 #12
0
        /// <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);
                    }
                }
            }
        }
コード例 #13
0
ファイル: Comments.cs プロジェクト: JosephAllen/DNNWiki
        /// <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;
            }
        }