Пример #1
0
        /// <summary>
        /// Add new blog
        /// </summary>
        /// <param name="item">Blog item</param>
        /// <returns>Saved blog with new ID</returns>
        public Models.Blog Add(BlogItem item)
        {
            // has to be on primary blog and be an admin
            // or blog allows create new on self registration
            if (!(Blog.CurrentInstance.IsPrimary && (Security.IsAdministrator || BlogSettings.Instance.CreateBlogOnSelfRegistration)))
            {
                throw new UnauthorizedAccessException();
            }

            string message;

            if (!BlogGenerator.ValidateProperties(item.Name, item.UserName, item.Email, out message))
            {
                throw new ApplicationException(message);
            }

            var coreBlog = BlogGenerator.CreateNewBlog(item.Name, item.UserName, item.Email, item.Password, out message);

            if (coreBlog == null || !string.IsNullOrWhiteSpace(message))
            {
                throw new ApplicationException("Failed to create the new blog.");
            }

            return(ToJson(coreBlog));
        }
Пример #2
0
        string CreateNewBlog()
        {
            string message = string.Empty;
            Blog   blog    = null;

            if (!BlogGenerator.ValidateProperties(BlogName.Text, UserName.Text, Email.Text, out message))
            {
                if (string.IsNullOrWhiteSpace(message))
                {
                    message = "Validation for new blog failed.";
                }
                return(message);
            }

            blog = BlogGenerator.CreateNewBlog(BlogName.Text, UserName.Text, Email.Text, Password.Text, out message);

            if (blog == null || !string.IsNullOrWhiteSpace(message))
            {
                return(message ?? "Failed to create the new blog.");
            }

            return(message);
        }
Пример #3
0
        string CreateNewBlog()
        {
            string message = string.Empty;
            Blog   blog    = null;

            if (!BlogGenerator.ValidateProperties(BlogName.Text, UserName.Text, Email.Text, out message))
            {
                if (string.IsNullOrWhiteSpace(message))
                {
                    message = "Validation for new blog failed.";
                }
                return(message);
            }

            // recaptcha check
            SetCaptcha(Form.Controls);

            if (captcha != null)
            {
                captcha.Validate();

                if (!captcha.IsValid)
                {
                    message = "Captcha invalid.";
                    return(message);
                }
            }

            blog = BlogGenerator.CreateNewBlog(BlogName.Text, UserName.Text, Email.Text, Password.Text, out message);

            if (blog == null || !string.IsNullOrWhiteSpace(message))
            {
                return(message ?? "Failed to create the new blog.");
            }

            return(message);
        }
Пример #4
0
 /// <summary>
 /// Setup new blog
 /// </summary>
 /// <param name="newBlog">New blog</param>
 /// <param name="userName">User name</param>
 /// <param name="email">Email</param>
 /// <param name="password">Password</param>
 /// <returns>True if successful</returns>
 public override bool SetupNewBlog(Blog newBlog, string userName, string email, string password)
 {
     return(BlogGenerator.CopyTemplateBlogFolder(newBlog.Name, userName, email, password));
 }