Exemplo n.º 1
0
        public HttpResponseMessage Put(Contact contact)
        {
            var repo = new FakeContactDatabase();
            repo.Edit(contact);

            var response = Request.CreateResponse(HttpStatusCode.OK, contact);

            string uri = Url.Link("DefaultApi", new {id = contact.ContactID});
            response.Headers.Location = new Uri(uri);

            return response;
        }
 public void Add(Contact contact)
 {
     if (_contacts.Any())
     {
         contact.ContactID = _contacts.Max(c => c.ContactID) + 1;
     }
     else
     {
         contact.ContactID = 1;
     }
     _contacts.Add(contact);
 }
 public void Edit(Contact contact)
 {
     Delete(contact.ContactID);
     _contacts.Add(contact);
 }