public void PutContact(int id,Contact contact) { contact.ContactId=id; if (!repository.Update(contact)) { throw new ArgumentNullException("Ops ! Contact object is null that was sended !"); } }
public void Post(Contact newContact) { if (newContact == null) { throw new ArgumentNullException("Opps ! Contact object is null that was sended !"); } newContact.ContactId= _nextId++; contacts.Add(newContact); }
public bool Update(Contact updatedContact) { if (updatedContact == null) { throw new ArgumentNullException("Opps ! Contact object is null that was sended !"); } else { var contact = this.Get(updatedContact.ContactId); if (contact.ContactId == -1) // there is no contact object with that id { return false; } contact.Name = updatedContact.Name; contact.Email = updatedContact.Email; contact.MobilePhone = updatedContact.MobilePhone; contact.WorkPhone = updatedContact.WorkPhone; contact.JobTitle = updatedContact.JobTitle; contact.Manager = updatedContact.Manager; contact.Departman = updatedContact.Departman; return true; } }
public void PostContact(Contact newContact) { repository.Post(newContact); }