public virtual async Task <BlogPostDto> CreateAsync(CreateBlogPostDto input) { return(await RequestAsync <BlogPostDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue { { typeof(CreateBlogPostDto), input } })); }
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); }
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); }
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)); }
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)); }
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)); }
public virtual Task <BlogPostDto> CreateAsync(CreateBlogPostDto input) { return(BlogPostAdminAppService.CreateAsync(input)); }