public async Task Should_Create_And_Update_A_Post() { var blogId = (await _blogRepository.GetListAsync()).First().Id; var title = "title"; var newTitle = "new title"; var content = "content"; var newPost = await _postAppService.CreateAsync(new CreatePostDto() { BlogId = blogId, Title = title, Content = content, Url = title.Replace(" ", "-") }); await _postAppService.UpdateAsync(newPost.Id, new UpdatePostDto() { BlogId = blogId, Title = newTitle, Content = content, Url = newTitle.Replace(" ", "-") }); UsingDbContext(context => { var post = context.Posts.FirstOrDefault(q => q.Id == newPost.Id); post.ShouldNotBeNull(); post.Title.ShouldBe(newTitle); post.Content.ShouldBe(content); post.BlogId.ShouldBe(blogId); post.Url.ShouldBe(newTitle.Replace(" ", "-")); }); }
public async Task <ActionResult> OnPost(Guid id, UpdatePostDto post) { var editedPost = await _postAppService.UpdateAsync(id, post); var blog = await _blogAppService.GetAsync(editedPost.BlogId); return(Redirect(Url.Content($"~/blog/{blog.ShortName}/{editedPost.Title}"))); }
public async Task<ActionResult> OnPost() { var post = new UpdatePostDto { BlogId = Post.BlogId, Title = Post.Title, Url = Post.Url, Content = Post.Content }; var editedPost = await _postAppService.UpdateAsync(Post.Id, post); var blog = await _blogAppService.GetAsync(editedPost.BlogId); return Redirect(Url.Content($"~/blog/{blog.ShortName}/{editedPost.Url}")); }
public async Task <ActionResult> OnPostAsync() { var post = new UpdatePostDto { BlogId = Post.BlogId, Title = Post.Title, Url = Post.Url, CoverImage = Post.CoverImage, Content = Post.Content, Tags = Post.Tags }; var editedPost = await _postAppService.UpdateAsync(Post.Id, post); var blog = await _blogAppService.GetAsync(editedPost.BlogId); return(RedirectToPage("/Blogs/Posts/Detail", new { blogShortName = blog.ShortName, postUrl = editedPost.Url })); }
public async Task <ActionResult> OnPostAsync() { var post = new UpdatePostDto { BlogId = Post.BlogId, Title = Post.Title, Url = Post.Url, CoverImage = Post.CoverImage, Content = Post.Content, Tags = Post.Tags }; var editedPost = await _postAppService.UpdateAsync(Post.Id, post); var blog = await _blogAppService.GetAsync(editedPost.BlogId); return(Redirect(Url.Content($"~/blog/{WebUtility.UrlEncode(blog.ShortName)}/{WebUtility.UrlEncode(editedPost.Url)}"))); }
public virtual async Task <ActionResult> OnPostAsync() { var post = new UpdatePostDto { BlogId = Post.BlogId, Title = Post.Title, Url = Post.Url, CoverImage = Post.CoverImage, Content = Post.Content, Tags = Post.Tags, Description = Post.Description.IsNullOrEmpty() ? Post.Content.Truncate(PostConsts.MaxSeoFriendlyDescriptionLength) : Post.Description }; var editedPost = await _postAppService.UpdateAsync(Post.Id, post); var blog = await _blogAppService.GetAsync(editedPost.BlogId); return(RedirectToPage("/Blogs/Posts/Detail", new { blogShortName = blog.ShortName, postUrl = editedPost.Url })); }
public async Task Should_Update_A_Post() { var blogId = (await _blogRepository.GetListAsync()).First().Id; var newTitle = "new title"; var newContent = "content"; var oldPost = (await _postRepository.GetListAsync()).FirstOrDefault();; await _postAppService.UpdateAsync(oldPost.Id, new UpdatePostDto() { BlogId = blogId, Title = newTitle, CoverImage = oldPost.CoverImage, Content = newContent, Url = newTitle.Replace(" ", "-") }); UsingDbContext(context => { var post = context.Posts.FirstOrDefault(q => q.Id == oldPost.Id); post.Title.ShouldBe(newTitle); post.Content.ShouldBe(newContent); }); }
public Task <PostWithDetailDto> UpdateAsync(Guid id, PostUpdateDto input) { return(_postAppService.UpdateAsync(id, input)); }