Example #1
0
        private bool TryAddComment(IdeaDataAdapter ideaDataAdapter, string authorName, string authorEmail, string content)
        {
            if (!Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(authorName))
                {
                    ModelState.AddModelError("authorName", "Your name is required.");
                }

                if (string.IsNullOrWhiteSpace(authorEmail))
                {
                    ModelState.AddModelError("authorEmail", "Email is required; it will not be displayed.");
                }
            }

            if (string.IsNullOrWhiteSpace(content))
            {
                ModelState.AddModelError("content", "Comment is required.");
            }

            if (!ModelState.IsValid)
            {
                return(false);
            }

            ideaDataAdapter.CreateComment(content, authorName, authorEmail);

            return(true);
        }
        private bool TryAddComment(IdeaDataAdapter ideaDataAdapter, string authorName, string authorEmail, string content)
        {
            if (!Request.IsAuthenticated)
            {
                if (string.IsNullOrWhiteSpace(authorName))
                {
                    ModelState.AddModelError("authorName", ResourceManager.GetString("Name_Required_Error"));
                }

                if (string.IsNullOrWhiteSpace(authorEmail))
                {
                    ModelState.AddModelError("authorEmail", ResourceManager.GetString("Email_Required_Error"));
                }
            }

            if (string.IsNullOrWhiteSpace(content) || string.IsNullOrWhiteSpace(StringHelper.GetCommentTitleFromContent(content)))
            {
                ModelState.AddModelError("content", ResourceManager.GetString("Comment_Required_Error"));
            }

            if (!ModelState.IsValid)
            {
                return(false);
            }

            ideaDataAdapter.CreateComment(content, authorName, authorEmail);

            return(true);
        }