예제 #1
0
        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);
            });
        }
예제 #2
0
파일: New.cshtml.cs 프로젝트: ZhaoRd/abp
        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));
 }