public async Task Should_Create_A_Post() { var blogId = (await _blogRepository.GetListAsync()).First().Id; var title = "test title"; var content = "test content"; var newPostDto = await _postAppService.CreateAsync(new CreatePostDto() { BlogId = blogId, Title = title, Content = content, Url = title.Replace(" ", "-") }); newPostDto.Id.ShouldNotBeNull(); UsingDbContext(context => { var post = context.Posts.FirstOrDefault(q => q.Title == title); post.ShouldNotBeNull(); post.Id.ShouldBe(newPostDto.Id); post.Title.ShouldBe(newPostDto.Title); post.Content.ShouldBe(newPostDto.Content); post.BlogId.ShouldBe(blogId); post.Url.ShouldBe(newPostDto.Url); }); }
public async Task <ActionResult> OnPost(CreatePostDto post) { var insertedPost = await _postAppService.CreateAsync(post); var blog = await _blogAppService.GetAsync(insertedPost.BlogId); return(Redirect(Url.Content($"~/blog/{blog.ShortName}/{insertedPost.Title}"))); }
public Task <PostWithDetailDto> CreateAsync(PostCreateDto input) { return(_postAppService.CreateAsync(input)); }