Esempio n. 1
0
 /// <summary>
 /// Delete a post
 /// </summary>
 /// <param name="slug">The post slug.</param>
 /// <param name="userAccessDetails">The user details</param>
 /// <returns>An async task</returns>
 public Task DeletePost(string slug, UserAccessDetails userAccessDetails)
 {
     return(this.ExecuteNonQuery(
                "cati.deletepost",
                parrameters =>
     {
         parrameters.AddWithValue("slug", slug);
         parrameters.AddWithValue("userid", userAccessDetails.UserId);
     }));
 }
Esempio n. 2
0
        /// <summary>
        /// Set a post.
        /// </summary>
        /// <param name="post">The post.</param>
        /// <param name="userAccessDetails">The user access details.</param>
        /// <returns>An async task.</returns>
        public async Task <Post> SetPost(Post post, UserAccessDetails userAccessDetails)
        {
            var results = await this.ExecuteReader(
                "cati.setpost",
                parmeters =>
            {
                parmeters.AddWithValue("id", post.MetaData.Id <= 0 ? null : (int?)post.MetaData.Id);
                parmeters.AddWithValue("slug", post.MetaData.Slug);
                parmeters.AddWithValue("title", post.MetaData.Title);
                parmeters.AddWithValue("description", post.MetaData.Description);
                parmeters.AddWithValue("userid", userAccessDetails.UserId);
                parmeters.AddWithValue("goeslive", post.MetaData.GoesLive);
                parmeters.AddWithValue("ispublished", post.MetaData.IsPublished);
                parmeters.AddWithValue("isreserved", post.MetaData.IsReserved);
                parmeters.AddWithValue("revision", post.MetaData.Revision);
                parmeters.AddWithValue("defaultimageid", (object)post.MetaData.DefaultImageId ?? DBNull.Value);
                parmeters.AddWithValue("publisheduser", post.MetaData.PublishedUser);

                var contentList = parmeters.AddWithValue(
                    "content",
                    CatiSqlDataLayer.GetPostContentRecord(post.PostContent));
                contentList.SqlDbType = SqlDbType.Structured;
                contentList.TypeName  = "cati.postcontentlist";
                var tagslist          = parmeters.AddWithValue(
                    "tags",
                    CatiSqlDataLayer.GetPostTagRecords(post.MetaData.Tags));
                tagslist.SqlDbType = SqlDbType.Structured;
                tagslist.TypeName  = "cati.tagslist";
            },
                SqlParsers.ParsePostMeta,
                SqlParsers.ParsePostContent,
                SqlParsers.ParsePostTag,
                SqlParsers.ParsePostAuditMapping);

            var metadata = results.Item1.First();
            var tags     = results.Item3;

            metadata.Tags = tags.Select(t => t.Tag);

            var history = results.Item4;

            metadata.History = history.Select(h => h.ToPostAuditHistory());

            return(new Post(results.Item1.First(), results.Item2));
        }