コード例 #1
0
 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();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }