public int SaveContactSummary(ContactSummary ContactSummary) { using (var entities = new ContactsEntities()) { ContactSummary result = entities.ContactSummaries.Add(ContactSummary); entities.SaveChanges(); return(result.ContactSummaryId); } }
public void SaveContactDetail(List <ContactDetail> ContactDetail, int ContactSummaryId) { using (var entities = new ContactsEntities()) { foreach (var contactDetail in ContactDetail) { ContactDetail dbContactDetail = new Database.ContactDetail(); dbContactDetail.Name = contactDetail.Name; dbContactDetail.Company = contactDetail.Company; dbContactDetail.Email = contactDetail.Email; dbContactDetail.Phone = contactDetail.Phone; dbContactDetail.ContactSummaryId = ContactSummaryId; entities.ContactDetails.Add(dbContactDetail); } entities.SaveChanges(); } }