예제 #1
0
 public Person(Guid id, string name, string surname, string patronymic, List<Telephone> telephones, Address address)
 {
     Id = id;
     Name = name;
     Surname = surname;
     Patronymic = patronymic;
     Telephones = telephones ?? new List<Telephone>();
     Address = address;
 }
예제 #2
0
        private void AddNewPersonButtonClick(object sender, EventArgs e)
        {
            string name = NameTb.Text;
            string surname = SurnameTb.Text;
            string patronymic = PatronymicTb.Text;
            string c = CityTb.Text;
            string s = StreetTb.Text;
            string h = HouseTb.Text;
            string f = FlatTb.Text;

            Person person = new Person(Guid.NewGuid(), name, surname, patronymic, new List<Telephone>(), null);
            Address address = new Address(person.Id, c, s, Convert.ToInt32(h), f.ToNullableInt32(), person);
            person.Address = address;

            _persons.Add(person);

            _phonesUnitOfWork.Repository<Address>().Save(address, address.PersonId);
            _phonesUnitOfWork.SaveChanges();
            _phonesUnitOfWork.Repository<Person>().Save(person, person.Id);
            _phonesUnitOfWork.SaveChanges();
        }