public Core.Data.Models.Blog Add(Core.Data.Models.BlogItem item)
 {
     var blog = new BlogEngine.Core.Data.Models.Blog()
     {
         Id = Guid.NewGuid()
     };
     return blog;
 }
 public Core.Data.Models.Blog FindById(Guid id)
 {
     var blog = new BlogEngine.Core.Data.Models.Blog()
     {
         Id = Guid.NewGuid()
     };
     return blog;
 }
        public Core.Data.Models.Blog Add(Core.Data.Models.BlogItem item)
        {
            var blog = new BlogEngine.Core.Data.Models.Blog()
            {
                Id = Guid.NewGuid()
            };

            return(blog);
        }
        public Core.Data.Models.Blog FindById(Guid id)
        {
            var blog = new BlogEngine.Core.Data.Models.Blog()
            {
                Id = Guid.NewGuid()
            };

            return(blog);
        }
Exemple #5
0
 static bool Save(Blog coreBlog, BlogEngine.Core.Data.Models.Blog jsonBlog)
 {
     coreBlog.Id   = jsonBlog.Id;
     coreBlog.Name = jsonBlog.Name;
     coreBlog.StorageContainerName            = jsonBlog.StorageContainerName;
     coreBlog.Hostname                        = jsonBlog.Hostname;
     coreBlog.IsAnyTextBeforeHostnameAccepted = jsonBlog.IsAnyTextBeforeHostnameAccepted;
     coreBlog.VirtualPath                     = jsonBlog.VirtualPath;
     coreBlog.IsActive                        = jsonBlog.IsActive;
     coreBlog.IsSiteAggregation               = jsonBlog.IsSiteAggregation;
     coreBlog.IsPrimary                       = jsonBlog.IsPrimary;
     //coreBlog.StorageLocation = PhysicalStorageLocation = HostingEnvironment.MapPath(blog.StorageLocation);
     coreBlog.Save();
     return(true);
 }
Exemple #6
0
 public HttpResponseMessage Update([FromBody] BlogEngine.Core.Data.Models.Blog blog)
 {
     try
     {
         repository.Update(blog);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (UnauthorizedAccessException)
     {
         return(Request.CreateResponse(HttpStatusCode.Unauthorized));
     }
     catch (Exception)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError));
     }
 }
Exemple #7
0
 /// <summary>
 /// Update blog
 /// </summary>
 /// <param name="blog">Blog to update</param>
 /// <returns>True on success</returns>
 public bool Update(Models.Blog blog)
 {
     // sub-blogs not allowed to see other blogs
     if (!(Blog.CurrentInstance.IsPrimary && Security.IsAdministrator))
     {
         throw new UnauthorizedAccessException();
     }
     try
     {
         var coreBlog = Blog.Blogs.FirstOrDefault(b => b.Id == blog.Id);
         return(Save(coreBlog, blog));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #8
0
        static BlogEngine.Core.Data.Models.Blog ToJson(Blog blog)
        {
            var jb = new BlogEngine.Core.Data.Models.Blog
            {
                Id   = blog.Id,
                Name = blog.Name,
                StorageContainerName            = blog.StorageContainerName,
                Hostname                        = blog.Hostname,
                IsAnyTextBeforeHostnameAccepted = blog.IsAnyTextBeforeHostnameAccepted,
                VirtualPath                     = blog.VirtualPath,
                IsActive                        = blog.IsActive,
                IsSiteAggregation               = blog.IsSiteAggregation,
                IsPrimary                       = blog.IsPrimary,
                RelativeWebRoot                 = blog.RelativeWebRoot,
                AbsoluteWebRoot                 = blog.AbsoluteWebRoot,
                PhysicalStorageLocation         = HostingEnvironment.MapPath(blog.StorageLocation),
                CanUserEdit                     = blog.CanUserEdit,
                CanUserDelete                   = blog.CanUserDelete
            };

            return(jb);
        }
Exemple #9
0
        /// <summary>
        /// Deletes a Blog from the database
        /// </summary>
        /// <param name="blog">
        /// The blog.
        /// </param>
        public override void DeleteBlog(Blog blog)
        {
            // Only deleting data from be_Blogs.  Data from the other tables
            // will be deleted in DeleteBlogStorageContainer().
            using (TransactionScope ts = new TransactionScope())
            {
                using (var conn = this.CreateConnection())
                {
                    if (conn.HasConnection)
                    {
                        var sqlQuery = string.Format("DELETE FROM {0}Blogs WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                        using (var cmd = conn.CreateTextCommand(sqlQuery))
                        {
                            cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                            cmd.ExecuteNonQuery();
                        }

                    }
                }
                ts.Complete();
            }
        }
        /// <summary>
        /// Gets all categories in database
        /// </summary>
        /// <returns>
        /// List of categories
        /// </returns>
        public override List<Category> FillCategories(Blog blog)
        {
            var categories = new List<Category>();

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    using (var cmd = conn.CreateTextCommand(string.Format("SELECT CategoryID, CategoryName, description, ParentID FROM {0}Categories WHERE BlogId = {1}blogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), blog.Id.ToString()));

                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var cat = new Category
                                    {
                                        Title = rdr.GetString(1),
                                        Description = rdr.IsDBNull(2) ? string.Empty : rdr.GetString(2),
                                        Parent = rdr.IsDBNull(3) ? (Guid?)null : new Guid(rdr.GetGuid(3).ToString()),
                                        Id = new Guid(rdr.GetGuid(0).ToString())
                                    };

                                categories.Add(cat);
                                cat.MarkOld();
                            }
                        }
                    }
                }
            }

            return categories;
        }
 /// <summary>
 /// Adds blog parameters to command.
 /// </summary>
 /// <param name="blog">
 /// The blog.
 /// </param>
 /// <param name="conn">
 /// The connection.
 /// </param>
 /// <param name="cmd">
 /// The command.
 /// </param>
 private void AddBlogParametersToCommand(
     Blog blog, DbConnectionHelper conn, DbCommand cmd)
 {
     var parms = cmd.Parameters;
     parms.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
     parms.Add(conn.CreateParameter(FormatParamName("BlogName"), blog.Name ?? string.Empty));
     parms.Add(conn.CreateParameter(FormatParamName("Hostname"), blog.Hostname ?? string.Empty));
     parms.Add(conn.CreateParameter(FormatParamName("IsAnyTextBeforeHostnameAccepted"), blog.IsAnyTextBeforeHostnameAccepted));
     parms.Add(conn.CreateParameter(FormatParamName("StorageContainerName"), blog.StorageContainerName));
     parms.Add(conn.CreateParameter(FormatParamName("VirtualPath"), blog.VirtualPath ?? string.Empty));
     parms.Add(conn.CreateParameter(FormatParamName("IsPrimary"), blog.IsPrimary));
     parms.Add(conn.CreateParameter(FormatParamName("IsActive"), blog.IsActive));
     parms.Add(conn.CreateParameter(FormatParamName("IsSiteAggregation"), blog.IsSiteAggregation));
 }
        /// <summary>
        /// Gets all Blogs in database
        /// </summary>
        /// <returns>
        /// List of Blogs
        /// </returns>
        public override List<Blog> FillBlogs()
        {
            var blogs = new List<Blog>();

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    using (var cmd = conn.CreateTextCommand(string.Format("SELECT BlogId, BlogName, Hostname, IsAnyTextBeforeHostnameAccepted, StorageContainerName, VirtualPath, IsPrimary, IsActive, IsSiteAggregation FROM {0}Blogs ", this.tablePrefix)))
                    {
                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var b = new Blog
                                {
                                    Id = rdr.GetGuid(0),
                                    Name = rdr.GetString(1),
                                    Hostname = rdr.GetString(2),
                                    IsAnyTextBeforeHostnameAccepted = rdr.GetBoolean(3),
                                    StorageContainerName = rdr.GetString(4),
                                    VirtualPath = rdr.GetString(5),
                                    IsPrimary = rdr.GetBoolean(6),
                                    IsActive = rdr.GetBoolean(7),
                                    IsSiteAggregation = rdr.GetBoolean(8)
                                };

                                blogs.Add(b);
                                b.MarkOld();
                            }
                        }
                    }
                }
            }

            return blogs;
        }
        /// <summary>
        /// Saves an existing Blog to the database
        /// </summary>
        /// <param name="blog">
        /// Blog to be saved
        /// </param>
        public override void UpdateBlog(Blog blog)
        {
            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("UPDATE {0}Blogs SET BlogName = {1}BlogName, Hostname = {1}Hostname, IsAnyTextBeforeHostnameAccepted = {1}IsAnyTextBeforeHostnameAccepted, StorageContainerName = {1}StorageContainerName, VirtualPath = {1}VirtualPath, IsPrimary = {1}IsPrimary, IsActive = {1}IsActive, IsSiteAggregation = {1}IsSiteAggregation WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        this.AddBlogParametersToCommand(blog, conn, cmd);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
        /// <summary>
        /// Setup new blog from scratch
        /// </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)
        {
            bool copyResult = BlogGenerator.CopyTemplateBlogFolder(newBlog.Name, userName, email, password);

            if (!copyResult)
            {
                Utils.Log("DbBlogProvider.SetupNewBlog", new Exception("Unsuccessful result from BlogGenerator.CopyTemplateBlogFolder."));
                return false;
            }

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    Blog existingBlog = Blog.Blogs.Where(b => b.Name == "Template").FirstOrDefault();

                    if (existingBlog == null)
                        existingBlog = Blog.Blogs[0];

                    // be_PingService
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PingService ( BlogID, Link ) " +
                        " SELECT {1}newblogid, Link " +
                        " FROM {0}PingService " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Rights
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Rights ( BlogId, RightName ) " +
                        " SELECT {1}newblogid, RightName " +
                        " FROM {0}Rights " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_RightRoles
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}RightRoles ( BlogId, RightName, Role ) " +
                        " SELECT {1}newblogid, RightName, Role " +
                        " FROM {0}RightRoles " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Settings
                    using (var cmd = conn.CreateTextCommand(string.Format("DELETE FROM {0}Settings WHERE BlogId = {1}blogid", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                        var settings = BlogGeneratorConfig.NewBlogSettings;
                        var setValue = "";

                        foreach (string key in settings.Keys)
                        {
                            cmd.CommandText = string.Format("INSERT INTO {0}Settings (BlogId, SettingName, SettingValue) VALUES ({1}blogid, {1}name, {1}value)", this.tablePrefix, this.parmPrefix);
                            cmd.Parameters.Clear();

                            setValue = settings[key];
                            if (setValue == "[BlogName]") setValue = newBlog.Name;
                            if (setValue == "[Description]") setValue = BlogGeneratorConfig.BlogDescription;

                            cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                            cmd.Parameters.Add(conn.CreateParameter(FormatParamName("name"), key));
                            cmd.Parameters.Add(conn.CreateParameter(FormatParamName("value"), setValue));
                            cmd.ExecuteNonQuery();
                        }
                    }

                    var catId = Guid.NewGuid().ToString();

                    // be_Categories
                    var sqlQuery = string.Format("INSERT INTO {0}Categories (BlogID, CategoryID, CategoryName, description, ParentID) VALUES ({1}blogid, {1}catid, {1}catname, {1}description, {1}parentid)", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        var parms = cmd.Parameters;
                        parms.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        parms.Add(conn.CreateParameter(FormatParamName("catid"), catId));
                        parms.Add(conn.CreateParameter(FormatParamName("catname"), "General"));
                        parms.Add(conn.CreateParameter(FormatParamName("description"), "General topics"));
                        parms.Add(conn.CreateParameter(FormatParamName("parentid"), (object)DBNull.Value));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Posts
                    Post post = new Post();
                    post.BlogId = newBlog.Id;
                    post.Title = BlogGeneratorConfig.PostTitle.Contains("{0}") ?
                        string.Format(BlogGeneratorConfig.PostTitle, newBlog.Name) :
                        BlogGeneratorConfig.PostTitle;
                    post.Slug = Utils.RemoveIllegalCharacters(post.Title);
                    post.Description = "The description is used as the meta description as well as shown in the related posts. It is recommended that you write a description, but not mandatory";
                    post.Author = userName;
                    string content = BlogGeneratorConfig.PostContent.Replace("&lt;", "<").Replace("&gt;", ">");
                    post.Content = content.Contains("{1}") ?
                        string.Format(content, userName, Utils.RelativeWebRoot + newBlog.Name + "/Account/login.aspx") : content;       
                    InsertPost(post);

                    // be_posttags
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}PostTag (BlogID, PostID, Tag) VALUES ({1}blogid, {1}id, {1}tag)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("id"), post.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("tag"), "welcome"));
                        cmd.ExecuteNonQuery();
                    }

                    // be_postcategories
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}PostCategory (BlogID, PostID, CategoryID) VALUES ({1}blogid, {1}id, {1}cat)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("id"), post.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("cat"), catId));
                        cmd.ExecuteNonQuery();
                    }

                    // be_DataStoreSettings
                    string widgetZone = BlogGeneratorConfig.WidgetZone;
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}DataStoreSettings (BlogId, ExtensionType, ExtensionId, Settings) VALUES ({1}blogid, {1}type, {1}id, {1}file)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("type"), 1));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("id"), "be_WIDGET_ZONE"));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("file"), widgetZone));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Users
                    sqlQuery = string.Format("INSERT INTO {0}Users (blogId, userName, password, emailAddress, lastLoginTime) VALUES ({1}blogid, {1}name, {1}pwd, {1}email, {1}login)", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        var parms = cmd.Parameters;
                        parms.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        parms.Add(conn.CreateParameter(FormatParamName("name"), userName));
                        parms.Add(conn.CreateParameter(FormatParamName("pwd"), Utils.HashPassword(password)));
                        parms.Add(conn.CreateParameter(FormatParamName("email"), email));
                        parms.Add(conn.CreateParameter(FormatParamName("login"), DateTime.Now));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Roles
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}Roles (BlogID, role) VALUES ({1}blogid, {1}role)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("role"), "Administrators"));
                        cmd.ExecuteNonQuery();
                    }
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}Roles (BlogID, role) VALUES ({1}blogid, {1}role)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("role"), "Anonymous"));
                        cmd.ExecuteNonQuery();
                    }

                    // be_UserRoles
                    using (var cmd = conn.CreateTextCommand(string.Format("INSERT INTO {0}UserRoles (BlogID, UserName, Role) VALUES ({1}blogID, {1}username, {1}role)", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogID"), newBlog.Id.ToString()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("username"), userName.Trim()));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("role"), "Administrators"));
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Sets up the required storage files/tables for a new Blog instance, from an existing blog instance.
        /// </summary>
        /// <param name="existingBlog">
        /// The existing blog to copy from.
        /// </param>
        /// <param name="newBlog">
        /// The new blog to copy to.
        /// </param>
        public override bool SetupBlogFromExistingBlog(Blog existingBlog, Blog newBlog)
        {
            // Even for the DbBlogProvider, we call newBlog.CopyExistingBlogFolderToNewBlogFolder().
            // The reasons are that a small number of extensions/widgets use App_Data even if
            // the DbBlogProvider is being used (Newsletter widget, Logger extension, and any
            // other custom components written by other people).  Also, even if the
            // DbBlogProvider is being used, the XmlMembershipProvider and XmlRoleProvider could
            // also be used, which stores data in App_Data.
            // So as a rule of thumb, whenever a new blog instance is created, we will create
            // a new folder in App_Data for that new instance, and copy all the files/folders in.

            bool copyResult = newBlog.CopyExistingBlogFolderToNewBlogFolder(existingBlog);

            if (!copyResult)
            {
                Utils.Log("DbBlogProvider.SetupBlogFromExistingBlog", new Exception("Unsuccessful result from newBlog.CopyExistingBlogFolderToNewBlogFolder."));
                return false;
            }

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    //
                    // For SQL CE compatibility, all the "newblogid" parameters below need to have their DBType set to DBType.String.
                    // This is done with the CreateParameter() overload that accepts a DBType.
                    //

                    // be_BlogRollItems
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}BlogRollItems ( BlogId, BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex ) " +
                        " SELECT {1}newblogid, BlogRollId, Title, Description, BlogUrl, FeedUrl, Xfn, SortIndex " +
                        " FROM {0}BlogRollItems " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Categories
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Categories ( BlogID, CategoryID, CategoryName, Description, ParentID ) " +
                        " SELECT {1}newblogid, CategoryID, CategoryName, Description, ParentID " +
                        " FROM {0}Categories " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_DataStoreSettings
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}DataStoreSettings ( BlogId, ExtensionType, ExtensionId, Settings ) " +
                        " SELECT {1}newblogid, ExtensionType, ExtensionId, Settings " +
                        " FROM {0}DataStoreSettings " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Pages
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Pages ( BlogID, PageID, Title, Description, PageContent, Keywords, DateCreated, DateModified, IsPublished, IsFrontPage, Parent, ShowInList, Slug, IsDeleted ) " +
                        " SELECT {1}newblogid, PageID, Title, Description, PageContent, Keywords, DateCreated, DateModified, IsPublished, IsFrontPage, Parent, ShowInList, Slug, IsDeleted " +
                        " FROM {0}Pages " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_PingService
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PingService ( BlogID, Link ) " +
                        " SELECT {1}newblogid, Link " +
                        " FROM {0}PingService " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Profiles
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Profiles ( BlogID, UserName, SettingName, SettingValue ) " +
                        " SELECT {1}newblogid, UserName, SettingName, SettingValue " +
                        " FROM {0}Profiles " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Referrers
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Referrers ( BlogId, ReferrerId, ReferralDay, ReferrerUrl, ReferralCount, Url, IsSpam ) " +
                        " SELECT {1}newblogid, ReferrerId, ReferralDay, ReferrerUrl, ReferralCount, Url, IsSpam " +
                        " FROM {0}Referrers " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Rights
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Rights ( BlogId, RightName ) " +
                        " SELECT {1}newblogid, RightName " +
                        " FROM {0}Rights " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_RightRoles
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}RightRoles ( BlogId, RightName, Role ) " +
                        " SELECT {1}newblogid, RightName, Role " +
                        " FROM {0}RightRoles " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Settings
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Settings ( BlogId, SettingName, SettingValue ) " +
                        " SELECT {1}newblogid, SettingName, SettingValue " +
                        " FROM {0}Settings " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_StopWords
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}StopWords ( BlogId, StopWord ) " +
                        " SELECT {1}newblogid, StopWord " +
                        " FROM {0}StopWords " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Posts
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Posts ( BlogId, PostID, Title, Description, PostContent, DateCreated, DateModified, Author, IsPublished, IsCommentEnabled, Raters, Rating, Slug, IsDeleted ) " +
                        " SELECT {1}newblogid, PostID, Title, Description, PostContent, DateCreated, DateModified, Author, IsPublished, IsCommentEnabled, Raters, Rating, Slug, IsDeleted " +
                        " FROM {0}Posts " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_PostCategory
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PostCategory ( BlogId, PostID, CategoryID ) " +
                        " SELECT {1}newblogid, PostID, CategoryID " +
                        " FROM {0}PostCategory " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_PostComment
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PostComment ( BlogId, PostCommentID, PostID, ParentCommentID, CommentDate, Author, Email, Website, Comment, Country, Ip, IsApproved, ModeratedBy, Avatar, IsSpam, IsDeleted ) " +
                        " SELECT {1}newblogid, PostCommentID, PostID, ParentCommentID, CommentDate, Author, Email, Website, Comment, Country, Ip, IsApproved, ModeratedBy, Avatar, IsSpam, IsDeleted " +
                        " FROM {0}PostComment " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_PostNotify
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PostNotify ( BlogId, PostID, NotifyAddress ) " +
                        " SELECT {1}newblogid, PostID, NotifyAddress " +
                        " FROM {0}PostNotify " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_PostTag
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}PostTag ( BlogId, PostID, Tag ) " +
                        " SELECT {1}newblogid, PostID, Tag " +
                        " FROM {0}PostTag " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    //////////////////////////////////////
                    // The DbMembershipProvider and DbRoleProvider may or may not be in use.
                    // Even if it's not in use, copy the rows for the Users and Roles tables.
                    //

                    // be_Users
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Users ( BlogId, UserName, Password, LastLoginTime, EmailAddress ) " +
                        " SELECT {1}newblogid, UserName, Password, LastLoginTime, EmailAddress " +
                        " FROM {0}Users " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_Roles
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}Roles ( BlogId, Role ) " +
                        " SELECT {1}newblogid, Role " +
                        " FROM {0}Roles " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    // be_UserRoles
                    using (var cmd = conn.CreateTextCommand(string.Format(
                        " INSERT INTO {0}UserRoles ( BlogId, UserName, Role ) " +
                        " SELECT {1}newblogid, UserName, Role " +
                        " FROM {0}UserRoles " +
                        " WHERE BlogID = {1}existingblogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("newblogid"), newBlog.Id.ToString(), System.Data.DbType.String));
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("existingblogid"), existingBlog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Adds a new blog to the database.
        /// </summary>
        /// <param name="blog">
        /// The blog.
        /// </param>
        public override void InsertBlog(Blog blog)
        {
            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("INSERT INTO {0}Blogs (BlogId, BlogName, Hostname, IsAnyTextBeforeHostnameAccepted, StorageContainerName, VirtualPath, IsPrimary, IsActive, IsSiteAggregation) VALUES ({1}BlogId, {1}BlogName, {1}Hostname, {1}IsAnyTextBeforeHostnameAccepted, {1}StorageContainerName, {1}VirtualPath, {1}IsPrimary, {1}IsActive, {1}IsSiteAggregation)", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        this.AddBlogParametersToCommand(blog, conn, cmd);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
Exemple #17
0
 static bool Save(Blog coreBlog, BlogEngine.Core.Data.Models.Blog jsonBlog)
 {
     coreBlog.Id = jsonBlog.Id;
     coreBlog.Name = jsonBlog.Name;
     coreBlog.StorageContainerName = jsonBlog.StorageContainerName;
     coreBlog.Hostname = jsonBlog.Hostname;
     coreBlog.IsAnyTextBeforeHostnameAccepted = jsonBlog.IsAnyTextBeforeHostnameAccepted;
     coreBlog.VirtualPath = jsonBlog.VirtualPath;
     coreBlog.IsActive = jsonBlog.IsActive;
     coreBlog.IsSiteAggregation = jsonBlog.IsSiteAggregation;
     coreBlog.IsPrimary = jsonBlog.IsPrimary;
     //coreBlog.StorageLocation = PhysicalStorageLocation = HostingEnvironment.MapPath(blog.StorageLocation);
     coreBlog.Save();
     return true;
 }
        /// <summary>
        /// Deletes the blog's storage container.
        /// </summary>
        /// <param name="blog">
        /// The blog.
        /// </param>
        public override bool DeleteBlogStorageContainer(Blog blog)
        {
            // First delete the blog folder.  Even the DB provider uses
            // the folder.  This is rare and is usually by widgets/extensions.
            if (!blog.DeleteBlogFolder())
            {
                return false;
            }

            // Delete data from all tables except for be_Blogs.  The blog
            // data from be_Blogs will be deleted in DeleteBlog().

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    // Note, the order here is important, especially for the DBs where
                    // foreign key constraints are setup (SQL Server is one).  The data
                    // in the referencing tables needs to be deleted first.

                    var sqlQuery = string.Format("DELETE FROM {0}PostTag WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}PostNotify WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}PostComment WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}PostCategory WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Posts WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}RightRoles WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Profiles WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}UserRoles WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Roles WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Rights WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Users WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Pages WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}StopWords WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Settings WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Referrers WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}PingService WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}DataStoreSettings WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}BlogRollItems WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }

                    sqlQuery = string.Format("DELETE FROM {0}Categories WHERE BlogId = {1}BlogId", this.tablePrefix, this.parmPrefix);
                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("BlogId"), blog.Id.ToString()));
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Gets the settings from the database
        /// </summary>
        /// <returns>
        /// dictionary of settings
        /// </returns>
        public override StringDictionary LoadSettings(Blog blog)
        {
            var dic = new StringDictionary();

            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    using (var cmd = conn.CreateTextCommand(string.Format("SELECT SettingName, SettingValue FROM {0}Settings WHERE BlogId = {1}blogid ", this.tablePrefix, this.parmPrefix)))
                    {
                        cmd.Parameters.Add(conn.CreateParameter(FormatParamName("blogid"), blog.Id.ToString()));

                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var name = rdr.GetString(0);
                                var value = rdr.GetString(1);

                                dic.Add(name, value);
                            }
                        }
                    }
                }
            }

            return dic;
        }
Exemple #20
0
        static BlogEngine.Core.Data.Models.Blog ToJson(Blog blog)
        {
            var jb = new BlogEngine.Core.Data.Models.Blog
            {
                Id = blog.Id,
                Name = blog.Name,
                StorageContainerName = blog.StorageContainerName,
                Hostname = blog.Hostname,
                IsAnyTextBeforeHostnameAccepted = blog.IsAnyTextBeforeHostnameAccepted,
                VirtualPath = blog.VirtualPath,
                IsActive = blog.IsActive,
                IsSiteAggregation = blog.IsSiteAggregation,
                IsPrimary = blog.IsPrimary,
                RelativeWebRoot = blog.RelativeWebRoot,
                AbsoluteWebRoot = blog.AbsoluteWebRoot,
                PhysicalStorageLocation = HostingEnvironment.MapPath(blog.StorageLocation),
                CanUserEdit = blog.CanUserEdit,
                CanUserDelete = blog.CanUserDelete
            };

            return jb;
        }
 public HttpResponseMessage Update([FromBody] BlogEngine.Core.Data.Models.Blog blog)
 {
     repository.Update(blog);
     return(Request.CreateResponse(HttpStatusCode.OK));
 }