コード例 #1
0
        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;
        }
コード例 #2
0
 public Contact Put(int id, Contact item)
 {
     repository[id] = item;
     return item;
 }