Beispiel #1
0
        /// <summary>
        /// Adds New Contact
        /// </summary>
        /// <param name="contact">Contact</param>
        public ContactDetail Add(ContactDetail contact)
        {
            var addedContact = context.ContactDetails.Add(contact);
            context.SaveChanges();

            return addedContact;
        }
Beispiel #2
0
 public void PutContact(ContactDetail contact)
 {
     if (repository.Update(contact)==0)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Updates Existing Contact
        /// </summary>
        /// <param name="contact">Contact</param>
        /// <returns>result</returns>
        public int Update(ContactDetail contact)
        {
            ContactDetail updateContact = context.ContactDetails.FirstOrDefault(c => c.ContactId == contact.ContactId);
            updateContact.FirstName = contact.FirstName.Trim();
            updateContact.MiddleName = contact.MiddleName.Trim();
            updateContact.LastName = contact.LastName.Trim();
            updateContact.EmailAddress = contact.EmailAddress.Trim();

            return context.SaveChanges();
        }
Beispiel #4
0
 public void PostContact(ContactDetail contact)
 {
     repository.Add(contact);
 }