public void Delete(Guid uniqueId)
        {
            var blogPostToDelete = BlogPosts.FirstOrDefault(i => i.UniqueId == uniqueId);

            if (blogPostToDelete != null)
            {
                BlogPosts.Remove(blogPostToDelete);
            }
        }
Exemplo n.º 2
0
        public async void RefreshContextAsync()
        {
            var previousSelectedBlogPostId = SelectedBlogPost?.Id;

            BlogPosts = await repository.GetBlogPostsAsync();

            Authors = await repository.GetAuthorsAsync();

            SelectedBlogPost = BlogPosts.FirstOrDefault(blogPost =>
                                                        previousSelectedBlogPostId.HasValue && blogPost.Id == previousSelectedBlogPostId.Value);
        }
Exemplo n.º 3
0
        public dynamic PostAction(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            var model =
                BlogPosts.FirstOrDefault(p => p.Status == PostStatus.Publish && p.Type == PostType.Post && p.Id.ToLower() == id.ToLower());

            return(View["post", model]);
        }
        public void Update(Guid uniqueId, BlogPost blogPost)
        {
            var blogPostToUpdate = BlogPosts.FirstOrDefault(i => i.UniqueId == uniqueId);

            if (blogPostToUpdate == null)
            {
                return;
            }
            blogPostToUpdate.Title         = blogPost.Title ?? blogPostToUpdate.Title;
            blogPostToUpdate.Description   = blogPost.Description ?? blogPostToUpdate.Description;
            blogPostToUpdate.Body          = blogPost.Body ?? blogPostToUpdate.Body;
            blogPostToUpdate.PublishedDate = blogPost.PublishedDate;
            blogPostToUpdate.Slug          = blogPost.Slug ?? blogPostToUpdate.Slug;
            blogPostToUpdate.Tags          = blogPost.Tags ?? blogPostToUpdate.Tags;
            blogPostToUpdate.ModifiedDate  = DateTime.Now.ToJavaScriptMilliseconds();
        }
 public BlogPost Get(Guid uniqueId)
 {
     return(BlogPosts.FirstOrDefault(i => i.UniqueId == uniqueId));
 }