Esempio n. 1
0
        public async Task <PostWithDetailsDto> CreateAsync(CreatePostDto input)
        {
            input.Url = await RenameUrlIfItAlreadyExistAsync(input.BlogId, input.Url);

            var post = new Post(
                id: GuidGenerator.Create(),
                blogId: input.BlogId,
                title: input.Title,
                coverImage: input.CoverImage,
                url: input.Url
                )
            {
                Content     = input.Content,
                Description = input.Description
            };

            await _postRepository.InsertAsync(post);

            var tagList = SplitTags(input.Tags);

            await SaveTags(tagList, post);
            await PublishPostChangedEventAsync(post.BlogId);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }
Esempio n. 2
0
        public async Task <PostWithDetailsDto> CreateAsync(CreatePostDto input)
        {
            var post = new Post(
                id: GuidGenerator.Create(),
                blogId: input.BlogId,
                creatorId: CurrentUser.GetId(),
                title: input.Title
                )
            {
                Content = input.Content
            };

            await _postRepository.InsertAsync(post);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }
Esempio n. 3
0
        public async Task <PostWithDetailsDto> CreateAsync(CreatePostDto input)
        {
            var post = new Post(
                id: GuidGenerator.Create(),
                blogId: input.BlogId,
                creatorId: CurrentUser.GetId(),
                title: input.Title,
                coverImage: input.CoverImage,
                url: input.Url
                )
            {
                Content = input.Content
            };

            await _postRepository.InsertAsync(post);

            var tagList = SplitTags(input.Tags);

            await SaveTags(tagList, post);

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