예제 #1
0
        public async Task <PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input)
        {
            var post = await _postRepository.GetAsync(id);

            post.SetTitle(input.Title);
            post.Content = input.Content;

            post = await _postRepository.UpdateAsync(post);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }
예제 #2
0
        public async Task <PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input)
        {
            var post = await _postRepository.GetAsync(id);

            post.SetTitle(input.Title);
            post.SetUrl(input.Url);
            post.Content = input.Content;

            post = await _postRepository.UpdateAsync(post);

            var tagList = SplitTags(input.Tags);

            await SaveTags(tagList, post);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }
예제 #3
0
        public async Task <PostWithDetailsDto> UpdateAsync(Guid id, UpdatePostDto input)
        {
            var post = await _postRepository.GetAsync(id);

            input.Url = await RenameUrlIfItAlreadyExistAsync(input.BlogId, input.Url, post);

            await AuthorizationService.CheckAsync(post, CommonOperations.Update);

            post.SetTitle(input.Title);
            post.SetUrl(input.Url);
            post.Content    = input.Content;
            post.CoverImage = input.CoverImage;

            post = await _postRepository.UpdateAsync(post);

            var tagList = SplitTags(input.Tags);

            await SaveTags(tagList, post);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }