public void AddNewMail(ContactViewModel newContact) { foreach (var r in newContact.Emails) { var create = new EmailsTable { Email = r.Email, ContactId = newContact.ContactId }; _db.EmailsTable.Add(create); } _db.SaveChanges(); }
public void AddNewNumbers(ContactViewModel newContact) { foreach (var r in newContact.Numbers) { var create = new NumbersTable { Number = r.Number, ContactId = newContact.ContactId }; _db.NumbersTable.Add(create); } _db.SaveChanges(); }
public void AddContact(ContactViewModel newContact) { newContact.ContactId = Guid.NewGuid(); var contact = new ContactsTable { ContactId = newContact.ContactId, Name = newContact.Name, Surname = newContact.Surname, Tag = newContact.Tag, Adress = newContact.Adress, PostalCode = newContact.PostalCode, City = newContact.City, Country = newContact.Country, EmailsTable = null, NumbersTable = null }; _db.ContactsTable.Add(contact); _db.SaveChanges(); _emailsService.AddNewMail(newContact); _numbersService.AddNewNumbers(newContact); }