public async Task <IActionResult> AddPost([FromQuery] int blogId, [FromBody] AddPostRequestViewModel viewModel) => await HandleResultAsync(() => _service.CreatePost(blogId, viewModel));
public async Task AddPost(int blogId, AddPostRequestViewModel viewModel) { await _context.Posts.AddAsync(new Post { Title = viewModel.Title, Content = viewModel.Content, BlogId = blogId }); await _context.SaveChangesAsync(); }
public async Task <ServiceResult <bool> > CreatePost(int blogId, AddPostRequestViewModel viewModel) { await _unitOfWork.PostRepository.AddPost(blogId, viewModel); return(ServiceResultFactory.Success(true)); }