public void Search()
        {
            SetARDataBinder(AutoLoadBehavior.NullIfInvalidKey);

            var filter = new UserFilter(DbSession);

            PropertyBag["filter"] = filter;
            if (IsPost || Request.QueryString.Keys.Cast <string>().Any(k => k.StartsWith("filter.")))
            {
                BindObjectInstance(filter, IsPost ? ParamStore.Form : ParamStore.QueryString, "filter", AutoLoadBehavior.NullIfInvalidKey);
                var result = filter.Find();
                PropertyBag["SearchResults"] = result;
            }
        }
示例#2
0
        public void Search_in_contacts_and_cout_results()
        {
            var client = DataMother.CreateTestClientWithAddressAndUser();

            session.SaveOrUpdate(client);
            var firstContact = new ContactGroup(ContactGroupType.General);
            var phone1       = RandomPhone();
            var phone2       = RandomPhone();
            var phone3       = RandomPhone();

            firstContact.AddContact(ContactType.Phone, phone1);
            firstContact.AddContact(ContactType.Phone, phone2);
            client.ContactGroupOwner.AddContactGroup(firstContact);
            var user = client.Users.FirstOrDefault();

            user.ContactGroup = new ContactGroup(ContactGroupType.General)
            {
                ContactGroupOwner = client.ContactGroupOwner
            };
            user.ContactGroup.AddContact(ContactType.Phone, phone3);
            var newUser = new User(client);

            newUser.Setup(session);
            client.AddUser(newUser);
            session.SaveOrUpdate(newUser);
            session.SaveOrUpdate(client);
            Flush();
            filter.SearchBy   = SearchUserBy.Auto;
            filter.SearchText = phone1;
            var result = filter.Find();

            Assert.That(result.Count, Is.EqualTo(2));
            filter.SearchText = phone3;
            result            = filter.Find();
            Assert.That(result.Count, Is.EqualTo(1));
        }