public class Product { public int Id { get; set; } public string Name { get; set; } public string Category { get; set; } public decimal Price { get; set; } }
[HttpPost] public HttpResponseMessage PostProduct(Product item) { if (item == null) return new HttpResponseMessage(HttpStatusCode.BadRequest); item = repository.Add(item); var response = Request.CreateResponse<Product>(HttpStatusCode.Created, item); string uri = Url.Link("DefaultApi", new { id = item.Id }); response.Headers.Location = new Uri(uri); return response; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)