public async Task <IActionResult> Update([FromBody] CreateUpdatePostRequest request) { if (request.Id == null) { return(new BadRequestResult()); } var existingPost = await this.postService.GetAsync(request.Id.Value); if (existingPost == null) { return(new BadRequestResult()); } existingPost.Title = request.Title; existingPost.Content = request.Content; await this.postService.UpdateAsync(existingPost); return(new OkResult()); }
public async Task <IActionResult> Create([FromBody] CreateUpdatePostRequest request) { var createdPost = await this.postService.CreateAsync(request.Title, request.Content); return(new JsonResult(createdPost)); }