// PUT api/posts/5 public void Put(int id, PostViewModel postViewModel) { var post = Mapper.Map<PostDto, PostViewModel>(iPublishService.GetById(id)); if (post == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } else { this.iPublishService.Edit(Mapper.Map<PostViewModel, PostDto>(postViewModel)); } }
// POST api/posts public void Post(PostViewModel postViewModel) { this.iPublishService.Publish(Mapper.Map<PostViewModel, PostDto>(postViewModel)); }