public void DoubleInsert()
        {
            Address address = new Address();
            address.Address1 = "TEST1";
            address.Address2 = "N/A";
            address.Town = "TEST TOWN";
            address.County = "TEST COUNTY";
            address.Country = "UK";
            address.Postcode = "XXXXXXX";
            address.Active = true;
            address.CreatedOn = DateTime.Now;
            address.LastUpdatedOn = DateTime.Now;

            Phone phone = new Phone();
            phone.Number = "01273234122";
            phone.Type = "HOME";
            phone.CreatedOn = DateTime.Now;
            phone.LastUpdatedOn = DateTime.Now;

            PersonalContact contact = new PersonalContact();
            contact.Firstname = "Amin";
            contact.Surname = "Mohammed-Coleman";
            contact.Email = "*****@*****.**";
            contact.DateOfBirth = DateTime.Now;

            // contact.NotifyBirthDay( false );
            contact.CreatedOn = DateTime.Now;
            contact.LastUpdatedOn = DateTime.Now;
            contact.Notes = "TEST";
            contact.AddAddressToContact(address);
            contact.AddPhoneToContact(phone);

            IFullTextSession s = Search.CreateFullTextSession(OpenSession());
            var tx = s.BeginTransaction();
            s.Save(contact);
            tx.Commit();

            s.Close();

            s = Search.CreateFullTextSession(OpenSession());
            tx = s.BeginTransaction();
            Term term = new Term("county", "county");
            TermQuery termQuery = new TermQuery(term);
            IList results = s.CreateFullTextQuery(termQuery).List();
            Assert.AreEqual(1, results.Count);
            s.Flush();
            s.Clear();

            s.Delete("from System.Object");
            tx.Commit();

            s.Close();
        }
Beispiel #2
0
        public void AddPhoneToContact(Phone phone)
        {
            if (phone == null)
            {
                throw new ArgumentNullException("phone");
            }

            phone.Contact = this;
            PhoneNumbers.Add(phone);
        }
Beispiel #3
0
        public void RemovePhoneFromContact(Phone phone)
        {
            if (phone == null)
            {
                throw new ArgumentNullException("phone");
            }

            if (PhoneNumbers.Contains(phone))
            {
                PhoneNumbers.Remove(phone);
            }
        }