BlogEngine.Core.Providers.DbBlogProvider.UpdatePage C# (CSharp) Method

UpdatePage() public method

Saves an existing page in the database
public UpdatePage ( Page page ) : void
page Page /// page to be saved ///
return void
        public override void UpdatePage(Page page)
        {
            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("UPDATE {0}Pages SET Title = {1}title, Description = {1}desc, PageContent = {1}content, DateCreated = {1}created, DateModified = {1}modified, Keywords = {1}keywords, IsPublished = {1}ispublished, IsFrontPage = {1}isfrontpage, Parent = {1}parent, ShowInList = {1}showinlist, Slug = {1}slug, IsDeleted = {1}isdeleted WHERE BlogID = {1}blogid AND PageID = {1}id", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        var p = cmd.Parameters;

                        p.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("id"), page.Id.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("title"), page.Title));
                        p.Add(conn.CreateParameter(FormatParamName("desc"), page.Description));
                        p.Add(conn.CreateParameter(FormatParamName("content"), page.Content));
                        p.Add(conn.CreateParameter(FormatParamName("created"), page.DateCreated.AddHours(-BlogSettings.Instance.Timezone)));
                        p.Add(conn.CreateParameter(FormatParamName("modified"), (page.DateModified == new DateTime() ? DateTime.Now : page.DateModified.AddHours(-BlogSettings.Instance.Timezone))));
                        p.Add(conn.CreateParameter(FormatParamName("keywords"), page.Keywords));
                        p.Add(conn.CreateParameter(FormatParamName("ispublished"), page.IsPublished));
                        p.Add(conn.CreateParameter(FormatParamName("isfrontpage"), page.IsFrontPage));
                        p.Add(conn.CreateParameter(FormatParamName("parent"), page.Parent.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("showinlist"), page.ShowInList));
                        p.Add(conn.CreateParameter(FormatParamName("slug"), page.Slug));
                        p.Add(conn.CreateParameter(FormatParamName("isdeleted"), page.IsDeleted));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }