public virtual async Task <BlogPostDto> CreateAsync(CreateBlogPostDto input)
 {
     return(await RequestAsync <BlogPostDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue
     {
         { typeof(CreateBlogPostDto), input }
     }));
 }
예제 #2
0
    public virtual async Task <BlogPostDto> CreateAndSendToReviewAsync(CreateBlogPostDto input)
    {
        var blogPost = await CreateAsync(input);

        await CurrentUnitOfWork.SaveChangesAsync();

        await SendToReviewAsync(blogPost.Id);

        blogPost.Status = BlogPostStatus.WaitingForReview;
        return(blogPost);
    }
예제 #3
0
    public virtual async Task <BlogPostDto> CreateAndPublishAsync(CreateBlogPostDto input)
    {
        var blogPost = await CreateAsync(input);

        await CurrentUnitOfWork.SaveChangesAsync();

        await PublishAsync(blogPost.Id);

        blogPost.Status = BlogPostStatus.Published;
        return(blogPost);
    }
예제 #4
0
        public async Task <ActionResult <BlogPost> > Create([FromBody] CreateBlogPostDto model)
        {
            _logger.LogInformation("Create blog post");
            var entity = new BlogPost()
            {
                LanguageId = 7,
                Title      = model.Title,
                Body       = model.Body
            };
            await _blogService.InsertBlogPostAsync(entity);

            return(CreatedAtAction(nameof(GetById), new { id = entity.Id }, entity));
        }
예제 #5
0
    public virtual async Task <BlogPostDto> CreateAsync(CreateBlogPostDto input)
    {
        var author = await UserLookupService.GetByIdAsync(CurrentUser.GetId());

        var blog = await BlogRepository.GetAsync(input.BlogId);

        var blogPost = await BlogPostManager.CreateAsync(
            author,
            blog,
            input.Title,
            input.Slug,
            input.ShortDescription,
            input.Content,
            input.CoverImageMediaId);

        await BlogPostRepository.InsertAsync(blogPost);

        return(ObjectMapper.Map <BlogPost, BlogPostDto>(blogPost));
    }
예제 #6
0
        public async Task CreateAsync_ShouldThrowException_WithNonExistingBlogId()
        {
            var title            = "Another My Awesome New Post";
            var slug             = "another-my-awesome-new-post";
            var shortDescription = "This blog is all about awesomeness 🤗!";

            var dto = new CreateBlogPostDto
            {
                // Non-existing Id
                BlogId           = Guid.NewGuid(),
                Title            = title,
                Slug             = slug,
                ShortDescription = shortDescription
            };

            var exception = await Should.ThrowAsync <EntityNotFoundException>(async() =>
                                                                              await blogPostAdminAppService.CreateAsync(dto));

            exception.EntityType.ShouldBe(typeof(Blog));
        }
예제 #7
0
 public virtual Task <BlogPostDto> CreateAsync(CreateBlogPostDto input)
 {
     return(BlogPostAdminAppService.CreateAsync(input));
 }