public HttpResponseMessage<Contact> Post(Contact item) { item.Id = (repository.Keys.Count == 0 ? 1 : repository.Keys.Max() + 1); repository.Add(item.Id, item); var response = new HttpResponseMessage<Contact>(item); response.StatusCode = HttpStatusCode.Created; response.Headers.Location = new Uri("/api/contacts/" + item.Id, UriKind.Relative); return response; }
public Contact Put(int id, Contact item) { repository[id] = item; return item; }