Ejemplo n.º 1
0
        string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish)
        {
            var user = ValidateUser(username, password);
            var comments = new PostComments();
            session.Store(comments);

            var publishDate = post.dateCreated == null
                                ? postScheduleringStrategy.Schedule()
                                : postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value));

            var newPost = new Models.Post
            {
                AuthorId = user.Id,
                Body = post.description,
                CommentsId = comments.Id,
                CreatedAt = DateTimeOffset.Now,
                SkipAutoReschedule = post.dateCreated != null,
                PublishAt = publishDate,
                Tags = post.categories,
                Title = post.title,
                CommentsCount = 0,
            };
            session.Store(newPost);
            session.SaveChanges();

            return newPost.Id;
        }
Ejemplo n.º 2
0
        string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish)
        {
            var user     = ValidateUser(username, password);
            var comments = new PostComments();

            session.Store(comments);

            var publishDate = post.dateCreated == null
                                ? postScheduleringStrategy.Schedule()
                                : postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value));

            var newPost = new Models.Post
            {
                AuthorId           = user.Id,
                Body               = post.description,
                CommentsId         = comments.Id,
                CreatedAt          = DateTimeOffset.Now,
                SkipAutoReschedule = post.dateCreated != null,
                PublishAt          = publishDate,
                Tags               = post.categories,
                Title              = post.title,
                CommentsCount      = 0,
            };

            session.Store(newPost);
            session.SaveChanges();

            return(newPost.Id);
        }
Ejemplo n.º 3
0
		string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish)
		{
			Models.Post newPost;
			using (var session = MvcApplication.DocumentStore.OpenSession())
			{
				var user = ValidateUser(username, password);
				var comments = new PostComments
								{
									Comments = new List<PostComments.Comment>(),
									Spam = new List<PostComments.Comment>()
								};
				session.Store(comments);

				var postScheduleringStrategy = new PostSchedulingStrategy(session, DateTimeOffset.Now);
				var publishDate = post.dateCreated == null
									? postScheduleringStrategy.Schedule()
									: postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value));

				newPost = new Models.Post
								{
									AuthorId = user.Id,
									Body = post.description,
									CommentsId = comments.Id,
									CreatedAt = DateTimeOffset.Now,
									SkipAutoReschedule = post.dateCreated != null,
									PublishAt = publishDate,
									Tags = post.categories,
									Title = post.title,
									CommentsCount = 0,
									AllowComments = true,
								};
				session.Store(newPost);
				comments.Post = new PostComments.PostReference
									{
										Id = newPost.Id,
										PublishAt = publishDate
									};

				session.SaveChanges();
			}

			return newPost.Id;
		}
Ejemplo n.º 4
0
        string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish)
        {
            Models.Post newPost;
            using (var session = MvcApplication.DocumentStore.OpenSession())
            {
                var user     = ValidateUser(username, password);
                var comments = new PostComments
                {
                    Comments = new List <PostComments.Comment>(),
                    Spam     = new List <PostComments.Comment>()
                };
                session.Store(comments);

                var postScheduleringStrategy = new PostSchedulingStrategy(session, DateTimeOffset.Now);
                var publishDate = post.dateCreated == null
                                                                        ? postScheduleringStrategy.Schedule()
                                                                        : postScheduleringStrategy.Schedule(new DateTimeOffset(post.dateCreated.Value));

                newPost = new Models.Post
                {
                    AuthorId           = user.Id,
                    Body               = post.description,
                    CommentsId         = comments.Id,
                    CreatedAt          = DateTimeOffset.Now,
                    SkipAutoReschedule = post.dateCreated != null,
                    PublishAt          = publishDate,
                    Tags               = post.categories,
                    Title              = post.title,
                    CommentsCount      = 0,
                    AllowComments      = true,
                };
                session.Store(newPost);
                comments.Post = new PostComments.PostReference
                {
                    Id        = newPost.Id,
                    PublishAt = publishDate
                };

                session.SaveChanges();
            }

            return(newPost.Id);
        }