public Item Patch(int id, Item newItem) { var item = _items.FirstOrDefault(x => x.Id == id); if (item == null) throw new HttpResponseException(HttpStatusCode.NotFound); if (newItem.Name != null) item.Name = newItem.Name; if (newItem.Country != null) item.Country = newItem.Country; return item; }
public HttpResponseMessage Get() { var item = new Item { Id = 1, Name = "Filip" }; return new HttpResponseMessage(HttpStatusCode.OK) { Content = new ProtoBufContent(item) }; }
public HttpResponseMessage Get(int id) { var item = new Item { Id = id, Name = "I'm manually content negotiatied!" }; var negotiator = Configuration.Services.GetContentNegotiator(); var result = negotiator.Negotiate(typeof(Item), Request, Configuration.Formatters); var bestMatchFormatter = result.Formatter; var mediaType = result.MediaType.MediaType; return new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent<Item>(item, bestMatchFormatter, mediaType) }; }
public Item Post(Item item) { //echo input return item; }
public void Post(Item item) { }