Example #1
0
    public async Task SetSlugAsync_ShouldWorkProperly_WithNonExistingSlug()
    {
        var newSlug = "yet-another-post";

        var blogPost = await blogPostRepository.GetAsync(cmsKitTestData.BlogPost_1_Id);

        await blogPostManager.SetSlugUrlAsync(blogPost, newSlug);

        blogPost.Slug.ShouldBe(newSlug);
    }
Example #2
0
        public virtual async Task <BlogPostDto> UpdateAsync(Guid id, UpdateBlogPostDto input)
        {
            var blogPost = await BlogPostRepository.GetAsync(id);

            blogPost.SetTitle(input.Title);
            blogPost.SetShortDescription(input.ShortDescription);

            if (blogPost.Slug != input.Slug)
            {
                await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug);
            }

            await BlogPostRepository.UpdateAsync(blogPost);

            return(ObjectMapper.Map <BlogPost, BlogPostDto>(blogPost));
        }
        public override async Task <BlogPostDto> UpdateAsync(Guid id, UpdateBlogPostDto input)
        {
            var blogPost = await BlogPostRepository.GetAsync(id);

            blogPost.SetTitle(input.Title);

            if (blogPost.Slug != input.Slug)
            {
                await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug);
            }

            MapToEntity(input, blogPost);

            await BlogPostManager.UpdateAsync(blogPost);

            return(await MapToGetOutputDtoAsync(blogPost));
        }
Example #4
0
    public virtual async Task <BlogPostDto> UpdateAsync(Guid id, UpdateBlogPostDto input)
    {
        var blogPost = await BlogPostRepository.GetAsync(id);

        blogPost.SetTitle(input.Title);
        blogPost.SetShortDescription(input.ShortDescription);
        blogPost.SetContent(input.Content);
        blogPost.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
        blogPost.CoverImageMediaId = input.CoverImageMediaId;

        if (blogPost.Slug != input.Slug)
        {
            await BlogPostManager.SetSlugUrlAsync(blogPost, input.Slug);
        }

        await BlogPostRepository.UpdateAsync(blogPost);

        return(ObjectMapper.Map <BlogPost, BlogPostDto>(blogPost));
    }