Пример #1
0
        public static CommentList getComments(BloggerService service, BlogLink blogLink, String postId)
        {
            CommentsResource.ListRequest commentsListRequest = null;
            try
            {
                commentsListRequest = new CommentsResource.ListRequest(service, blogLink.blogId, postId);
            }
            catch (Exception ex)
            {
                DAL.InsertAccessLog(blogLink.blogName, blogLink.userId, ex.ToString());
            }

            return(commentsListRequest.Fetch());
        }
Пример #2
0
        public static Post insertPost(BloggerService service, BlogLink blogLink, String content)
        {
            Post postContent = new Post();

            postContent.Title   = "#throughglass";
            postContent.Content = content;
            postContent.Labels  = new List <String>()
            {
                "throughglass"
            };

            PostsResource prInsertAction = service.Posts;

            return(prInsertAction.Insert(postContent, blogLink.blogId).Fetch());
        }
Пример #3
0
        public static Post updatePostTitle(BloggerService service, BlogLink blogLink, PostManager postManager, String content)
        {
            Post patchContent = new Post();

            patchContent.Title = content;

            patchContent.Content = postManager.postContent;

            patchContent.Id = postManager.postId;

            patchContent.Labels = new List <String>()
            {
                "throughglass"
            };

            PostsResource.PatchRequest prPatchRequest = service.Posts.Patch(patchContent, blogLink.blogId, postManager.postId);

            return(prPatchRequest.Fetch());
        }
Пример #4
0
        public static void InsertIntoBlogLink(BlogLink blogLink)
        {
            using (SqlConnection myConnection = new SqlConnection("Data Source=" + DATA_SOURCE + "; Initial Catalog=" + CATALOG + "; User ID=" + USER_ID + "; Password='******';"))
            {
                SqlCommand myCommand = new SqlCommand("INSERT_BLOG_LINK", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;

                // db will generate auto new id
                myCommand.Parameters.AddWithValue("@USER_ID", blogLink.userId);
                myCommand.Parameters.AddWithValue("@CONTACT_ID", blogLink.contactId);
                myCommand.Parameters.AddWithValue("@SUBSCRIPTION_ID", blogLink.subscriptionId);
                myCommand.Parameters.AddWithValue("@BLOG_ID", blogLink.blogId);
                myCommand.Parameters.AddWithValue("@BLOG_NAME", blogLink.blogName);
                myCommand.Parameters.AddWithValue("@SOURCE", blogLink.source);
                myCommand.Parameters.AddWithValue("@IS_ACTIVE", blogLink.isActive);

                myConnection.Open();
                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }
        }
Пример #5
0
        public static BlogLink GetActiveBlogLinkByUserId(String userId)
        {
            BlogLink blogLink = new BlogLink()
            {
                blogId = "-1"
            };

            using (SqlConnection myConnection = new SqlConnection("Data Source=" + DATA_SOURCE + "; Initial Catalog=" + CATALOG + "; User ID=" + USER_ID + "; Password='******';"))
            {
                SqlCommand myCommand = new SqlCommand("GET_BLOG_ID_BY_USERID", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;

                // db will generate auto new id
                myCommand.Parameters.AddWithValue("@USER_ID", userId);

                myConnection.Open();

                SqlDataReader reader = myCommand.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        blogLink.userId         = reader["USER_ID"].ToString();
                        blogLink.contactId      = reader["CONTACT_ID"].ToString();
                        blogLink.subscriptionId = reader["SUBSCRIPTION_ID"].ToString();
                        blogLink.blogId         = reader["BLOG_ID"].ToString();
                        blogLink.blogName       = reader["BLOG_NAME"].ToString();
                        blogLink.source         = reader["SOURCE"].ToString();
                        blogLink.isActive       = Convert.ToBoolean(reader["IS_ACTIVE"]);
                    }
                }
                myConnection.Close();
            }
            return(blogLink);
        }
Пример #6
0
        public static void deletePost(BloggerService service, BlogLink blogLink, PostManager postManager)
        {
            PostsResource prDeleteAction = service.Posts;

            prDeleteAction.Delete(blogLink.blogId, postManager.postId).Fetch();
        }
Пример #7
0
 public static PostList getPosts(BloggerService service, BlogLink blogLink)
 {
     PostsResource.ListRequest postListRequest = service.Posts.List(blogLink.blogId);
     return(postListRequest.Fetch());
 }