// Update Contacts
 public HttpResponseMessage Put(int id, Contact value)
 {
     try
     {
         value.Id = id;
         _contacts.UpdateContact(id, value);
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
     }
     return Request.CreateResponse(HttpStatusCode.OK);
 }
 public Contact AddContact(Contact item)
 {
     try
     {
         context.Contacts.Add(item);
         context.SaveChanges();
         return item;
     }
     catch
     {
         throw;
     }
 }
 // Insert Contact
 public HttpResponseMessage Post(Contact value)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Contact contact = _contacts.AddContact(value);
             var response = Request.CreateResponse<Contact>(HttpStatusCode.Created, contact);
             return response;
         }
         else
         {
             return Request.CreateResponse(HttpStatusCode.InternalServerError, "Model state is invalid");
         }
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
     }
 }
        public bool UpdateContact(int id, Contact item)
        {
            try
            {
                var contact = context.Contacts.SingleOrDefault(c => c.Id == id);

                if( contact == null)
                    throw new Exception(string.Format("Contact with id: '{0}' not found", id.ToString()));

                contact.Name = item.Name;
                contact.Email = item.Email;
                contact.Phone = item.Phone;

                context.Entry(contact).State = EntityState.Modified;
                context.SaveChanges();
                return true;
            }
            catch
            {
                throw;
            }
        }