Esempio n. 1
0
        private bool TryAddIdea(IdeaForumDataAdapter ideaForumDataAdapter, string title, string authorName, string authorEmail, string copy)
        {
            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(title))
            {
                ModelState.AddModelError("title", "Idea is required.");
            }

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

            ideaForumDataAdapter.CreateIdea(title, copy, authorName, authorEmail);

            return(true);
        }
        private bool TryAddIdea(IdeaForumDataAdapter ideaForumDataAdapter, string title, string authorName, string authorEmail, string copy)
        {
            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(title))
            {
                ModelState.AddModelError("title", ResourceManager.GetString("Idea_Is_Required_Error"));
            }

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

            ideaForumDataAdapter.CreateIdea(title, copy, authorName, authorEmail);

            return(true);
        }