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

SaveQuickNote() public method

Save quick note
public SaveQuickNote ( QuickNote note ) : void
note BlogEngine.Core.Notes.QuickNote Quick note
return void
        public override void SaveQuickNote(QuickNote note)
        {
            using (var conn = this.CreateConnection())
            {
                if (conn.HasConnection)
                {
                    var sqlQuery = string.Format("select count(*) from {0}QuickNotes where NoteId = {1}noteid", this.tablePrefix, this.parmPrefix);
                    object cnt;

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {
                        var p = cmd.Parameters;
                        p.Add(conn.CreateParameter(FormatParamName("noteid"), note.Id));
                        cnt = cmd.ExecuteScalar();
                    }

                    if (int.Parse(cnt.ToString()) > 0)
                        sqlQuery = string.Format("update {0}QuickNotes set Note = {1}note, updated = {1}updated where NoteId = {1}noteid", this.tablePrefix, this.parmPrefix);
                    else
                        sqlQuery = string.Format("insert into {0}QuickNotes (NoteId, BlogId, UserName, Note, Updated) values ({1}noteid, {1}blogid, {1}username, {1}note, {1}updated)", this.tablePrefix, this.parmPrefix);

                    using (var cmd = conn.CreateTextCommand(sqlQuery))
                    {

                        var p = cmd.Parameters;

                        p.Add(conn.CreateParameter(FormatParamName("noteid"), note.Id));
                        p.Add(conn.CreateParameter(FormatParamName("blogid"), Blog.CurrentInstance.Id.ToString()));
                        p.Add(conn.CreateParameter(FormatParamName("username"), note.Author));
                        p.Add(conn.CreateParameter(FormatParamName("note"), note.Note));
                        p.Add(conn.CreateParameter(FormatParamName("updated"), DateTime.Now.AddHours(-BlogSettings.Instance.Timezone)));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }