// POST api/post/ public async Task <HttpResponseMessage> Post(PostWEB value) { if (value == null) { throw new Exception(); } var mapper = new Mapper(WEBtoBLL); PostBLL postBLL = mapper.Map <PostWEB, PostBLL>(value); await service.Create(postBLL); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
// GET api/post/5 public HttpResponseMessage Get(int id) { PostBLL Post = service.GetOne(id); var mapper = new Mapper(BLLtoWEB); PostWEB PostWEB = mapper.Map <PostBLL, PostWEB>(Post); string responseBody = JsonSerializer.Serialize(PostWEB); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(responseBody); return(response); }