// GET api/product/5 public Product Get([FromUri]Guid id) { ProductServiceClient productService = new iSnackServiceReference.ProductServiceClient(); ProductEntity product = productService.GetByID(id); var result = ObjectMapperManager.DefaultInstance.GetMapper<ProductEntity, Product>().Map(product); if (product == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return result; }
// DELETE api/product/5 public HttpResponseMessage Delete([FromUri]Guid id) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); ProductServiceClient productService = new iSnackServiceReference.ProductServiceClient(); ProductEntity product = productService.GetByID(id); if (product == null) { response = Request.CreateResponse(HttpStatusCode.NotFound); } else { bool isSucc = productService.Delete(id); if (isSucc) { response = Request.CreateResponse(HttpStatusCode.OK, product); } } return Request.CreateResponse(HttpStatusCode.OK, product); }