public async Task <ActionResult> Post([FromBody] BlogCreationDTO blogCreationDTO) { var insertedBlog = await _blogService.InsertAsync(blogCreationDTO); await _notificationSender.SendBlogPostNotificationsAsync(insertedBlog); return(new CreatedAtRouteResult("GetBlog", new { insertedBlog.ID }, insertedBlog)); }
private List <BlogCategory> MapCategoryIDs(BlogCreationDTO blogCreationDTO, Blog blog) { return(blogCreationDTO.CategoryIDs .Select(ci => new BlogCategory() { CategoryID = ci }) .ToList()); }
public async Task <BlogDTO> InsertAsync(BlogCreationDTO blogCreationDTO) { Preconditions.NotNull(blogCreationDTO, nameof(blogCreationDTO)); var blogEntity = ToEntity(blogCreationDTO); blogEntity.EstimatedReadingTimeInMinutes = _readingTimeEstimator.GetEstimatedReadingTime(blogEntity.HTMLContent); await AssignUserID(blogEntity); var insertedEntity = await _blogRepository.InsertAsync(blogEntity); return(ToDTO(insertedEntity)); }
private Blog ToEntity(BlogCreationDTO blogCreationDTO) => _mapper.Map <Blog>(blogCreationDTO);
public async Task <BlogDTO> CreateAsync(BlogCreationDTO blogCreationDTO) { return(await _httpService.PostHelperAsync <BlogCreationDTO, BlogDTO>(BlogClientEndpoints.Base, blogCreationDTO)); }